How to create a form Widget with validators in 3 simple steps I. C8 Global key in a Stateful Widget II. Add Validator to TextFormField Widget III. With Form Key, see Current State and Invoke the validate method Step I: C8 Global key in a Stateful Widget class MyCustomFormState extends State<MyCustomForm> { final _formKey = GlobalKey<FormState>(); @override Widget build(BuildContext context) { return Form( key: _formKey, child: HomePage());}} Step II: Add Validator to TextFormField Widget TextFormField( validator: (form_value) { if (form_value.isEmpty) { return 'Please enter some text'} return null; },); Step III: With Form Key, see Current State and Invoke the validate method RaisedButton( onPressed: () { if (_formKey.currentState.validate()) { Scaffold...
Fat Arrow: "=>" is "{}" Dynamic Vs Object : Semantic Difference for accepting any type, difference is Hashcode is property on Object and Dynamic is when system cannot properly express any type that dev want to use. Print to console with "print()" Quick Guide to Darts Constructor: Used to create object new keyword is optional in Dart2 Declaring Constructor by creating function with same name as class/ syntactic constructor class Point { num x , y ; Point ( num x , num y ) { // There's a better way to do this, stay tuned. this . x = x ; this . y = y ; } } class Point { num x , y ; Point ( this. x , this. y ); } Named Constructor , class name with additional identifier Gives extra clarity when implement multiple constructor within a class Constructor are not inherited, subclass do not inherit superclass's named constructor class Point { num x , y ; Point ( this ....
What is BLOC (Business Logic Component)? A component that converts incoming Events (Streams) to outgoing States (Streams). Events - Inputs to a bloc e.g. in response of user interaction States - Outputs of a bloc and is part of application state. Notified system to redraw UI with build() Transition - Change of state, consist of current, transition and next state Why Stream? Stream - "container" for asynchronous data Asynchronous Programming Future (computation that is not completed immediately) Vs Stream (sequence/iterable, instead of asking for it, will inform you of event that is ready) Receive by: await for (hint hint for loop) Streams: Single Subscription stream - listened once Broadcast Stream - more than one listener can listen at the same time and it can be listened again Methods that: Process stream and return a result, Modify by returning a new stream based on original, Transform and Listen which return StreamSubscript...
Comments
Post a Comment