Created
October 22, 2022 19:08
-
-
Save yarn-rp/cd758c5b7607180ff6c8c02ea49151ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NewIntCaseWidget extends CaseWidget<int> { | |
NewIntCaseWidget({ | |
super.key, | |
required int super.value, | |
}) { | |
onEquals(0, (value, context) => Text('Value is zero')); | |
onEquals(1, (value, context) => Text('Value is 1')); | |
onLessThan(1, (value, context) => Text('Value is less than 1')); | |
onGreaterThan(1, (value, context) => Text('Value is greater than 1')); | |
} | |
} | |
class OldIntCaseWidget extends StatelessWidget { | |
final int value; | |
const OldIntCaseWidget({ | |
super.key, | |
required this.value, | |
}); | |
@override | |
Widget build(BuildContext context) { | |
if (value == 0) { | |
return Text('Value is zero'); | |
} | |
if (value == 1) { | |
return Text('Value is 1'); | |
} | |
if (value < 1) { | |
return Text('Value is less than 1'); | |
} | |
if (value > 1) { | |
return Text('Value is greater than 1'); | |
} | |
return Text('$value not mathing any posibility'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment