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
| TextEditingController controller = TextEditingController(); | |
| TextField( | |
| keyboardType: TextInputType.number, | |
| textCapitalization: TextCapitalization.sentences, | |
| textAlign: TextAlign.center, | |
| style: TextStyle(color: Colors.red, fontWeight: FontWeight.w300), |
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
| FocusManager.instance.primaryFocus?.unfocus() | |
| #use cases | |
| return GestureDetector( | |
| onTap: () => FocusManager.instance.primaryFocus?.unfocus(), | |
| child: Scaffold( | |
| appBar: AppBar( | |
| title: Text('Login'), | |
| ), | |
| body: Body(), | |
| ), |
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
| Material( | |
| elevation: 10, | |
| borderRadius: BorderRadius.all(Radius.circular(50)), | |
| child: Container( | |
| height: 100, | |
| width: 200, | |
| decoration: BoxDecoration( | |
| color: Colors.amber, | |
| borderRadius: BorderRadius.all(Radius.circular(50)), | |
| ), |
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
| #division entière | |
| int n = 7 ~/ 3; | |
| résult by excess | |
| int exces = (7/3).ceil(); | |
| result by default | |
| int dfault = (7/3).floor(); | |
| print(n); | |
| print(exces); | |
| print(dfault); |
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
| double num1 = double.parse((12.3412).toStringAsFixed(2)); | |
| // 12.34 | |
| double num2 = double.parse((12.5668).toStringAsFixed(2)); | |
| // 12.57 | |
| double num3 = double.parse((-12.3412).toStringAsFixed(2)); | |
| // -12.34 | |
| double num4 = double.parse((-12.3456).toStringAsFixed(2)); |
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 SimpleBlocObserver extends BlocObserver { | |
| @override | |
| void onEvent(Bloc bloc, Object? event) { | |
| super.onEvent(bloc, event); | |
| print(event); | |
| } | |
| @override | |
| void onTransition(Bloc bloc, Transition transition) { | |
| super.onTransition(bloc, transition); |
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
| typedef Int2VoidFunc = void Function(int); | |
| // or: typedef void Int2VoidFunc(int arg); | |
| class MyOtherClass { | |
| final Int2VoidFunc callback; | |
| MyOtherClass(this.callback); | |
| void callCallaback() { callback(5); } | |
| } |
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
| //Set the value if it doesn't | |
| //You may be tempted to implement some conditional logic to handle this: | |
| class ShoppingCart { | |
| final Map<String, int> items = {}; | |
| void add(String key, int quantity) { | |
| if (items.containsKey(key)) { | |
| // item exists: update it | |
| items[key] = quantity + items[key]!; |
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
| Stack( | |
| children: [ | |
| Center( | |
| child: Container( | |
| height: 200, | |
| width: 200, | |
| decoration: new BoxDecoration( | |
| borderRadius: BorderRadius.circular(20.0), | |
| ), | |
| child: FlutterLogo(), |
OlderNewer