Apply Style on specific boolean value? #548
AlexanderThiele
started this conversation in
General
Replies: 1 comment 3 replies
-
|
If I understand you correctly, this may help resolve your issue. class CustomContainer extends StatelessWidget {
const CustomContainer({
super.key,
this.hasError = false,
this.isFilled = false,
});
final bool hasError;
final bool isFilled;
@override
Widget build(BuildContext context) {
return Box(
style: Style(
$box.color(m.Colors.grey),
isFilled ? $box.color(m.Colors.blue) : null,
hasError ? $box.color(m.Colors.red) : null,
),
);
}
}
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey!
i need to apply some styles depending on custom boolean. I created my own Variant for it, but i wonder if it already exist in any form in this plugin? Maybe i missed a part.
Just imagine you have 2 Boolean and depending on that boolean, you want to apply a different color. This use case seems so simple, but i could not find a good solution.
Beta Was this translation helpful? Give feedback.
All reactions