-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
name conflicts with the origin properties #73
Comments
I would actually not recommend using methods for properties of Text since each method creates a new Text widget. If you have any suggestions for a solution, I would like to hear! |
according dart document about const If you can eventually generate a const Text(), there should be no runtime performance loss. Cuz const in dart is not const as we understand it in other languages, So, how about fixing the known naming conflicts first? |
I agree. Don't want to deal with code generation if there are other alternatives. I have previously thought about creating a separate Text data class with non-mutable members. Then add a method for generating a text widget from the class. StyledText("some text")
.bold()
.size(20)
.toText() or something like that. Btw i do not really prioritize development of this library at the moment. I am open for discussion but I won't make large changes in the near future. If you would like to contribute I would be more than happy to accept contributions. |
Update: I learned this in an unrelated official video. class Basic extends StatelessWidget {
const Basic({Key? key}) : super(key: key);
static final text = const Text(
'some text',
)
.textScale(1.5)
.italic()
.bold()
.fontWeight(FontWeight.w200)
.fontSize(20)
.fontFamily('sans-serif')
.letterSpacing(5.0)
.wordSpacing(20.0)
.textShadow(
color: Colors.black,
blurRadius: 10.0,
offset: const Offset(5.0, 5.0),
)
.textElevation(11)
.textColor(Colors.green);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text,
],
);
}
} |
that's an interesting approach! But it is still somewhat unsatisfactory. It works well as long as the widget is final. If you later decide to include an animation on the text, its no longer as easy to include without impacting performance. |
This reminds me that there is a hookBuilder in flutter_hooks, which is the equivalent of a widget scope, that is used to solve the problem you mentioned, as ref |
.textWidthBasic() .textDirection() conflict with the origin same name properties
Flutter 2.13.0-0.2.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 8662e22bac (4 days ago) • 2022-04-20 08:21:52 -0700
Engine • revision 24a02fa5ee
Tools • Dart 2.17.0 (build 2.17.0-266.5.beta) • DevTools 2.12.2
The text was updated successfully, but these errors were encountered: