Answers for "flutter form widget"

3

flutter inhereted widget

class MyInherited extends InheritedWidget {
  const MyInherited({
    Key? key,
    required Widget child,
  }) : super(key: key, child: child);


  // Here be dragons: null check (!) used, but if there's no
  // MyInhereted over where you used it this will throw.
  static MyInherited of(BuildContext context) {
    return context.dependOnInheritedWidgetOfExactType<MyInherited>()!;
  }

  //if you have properties, it should look something like:
  // bool updateShouldNotify(MyInherited old) => old.prop !== new.prop;
  
  //if you don't: 
  @override
  bool updateShouldNotify(MyInherited old) => false;
}
Posted by: Guest on December-03-2020
3

flutter form

final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
Form(
      key: _formKey,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          TextFormField(
            decoration: const InputDecoration(
              hintText: 'Enter your email',
            ),
          ),
          ElevatedButton(
            onPressed: () {  },
            child: const Text('Submit'),
          ),
        ],
      ),
    ),
Posted by: Guest on August-30-2021

Browse Popular Code Answers by Language