Advertisement
Guest User

Untitled

a guest
Dec 28th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.81 KB | None | 0 0
  1.  
  2.   final _loginFormKey = GlobalKey<FormState>();
  3.   final _emailKey = GlobalKey<FormFieldState>();
  4.   final _passwordKey = GlobalKey<FormFieldState>();
  5.  
  6. .
  7. .
  8. .
  9.   void _validateEmail() {
  10.     if (_emailKey.currentState.validate()) {
  11.       print('valid');
  12.     } else {
  13.       print('invalid');
  14.     }
  15.   }
  16.  
  17.   void _validatePassword() {
  18.     _passwordKey.currentState.validate();
  19.   }
  20.  
  21. .
  22. .
  23. .
  24. Widget loginWidget() {
  25.     return Column(
  26.       children: [
  27.         Form(
  28.           key: _loginFormKey,
  29.           child:
  30.           Column(
  31.             children: [
  32.             Padding(
  33.               padding: EdgeInsets.only(bottom: 7),
  34.               child: EltaFormField(
  35.                 key: _emailKey,
  36.                 placeholderText: 'Ваш email',
  37.                 keyboardType: TextInputType.emailAddress,
  38.                 type: EltaFormFieldType.normal,
  39.                 validator: this.widget.emailValidator.validate,
  40.                 onSaved: (String value) {
  41.                   _email = value;
  42.                   },
  43.                 onEditingComplete: () {
  44.                   _validateEmail();
  45.                  },
  46.                 onTap: () {
  47.                   _pushToTextField();
  48.                   },
  49.                 ),
  50.               ),
  51.             EltaFormField(
  52.               key: _passwordKey,
  53.               placeholderText: 'Ваш пароль',
  54.               type: EltaFormFieldType.obscure,
  55.               validator: this.widget.passwordValidator.validate,
  56.               onSaved: (String value) {
  57.                 _password = value;
  58.               },
  59.               onEditingComplete: () {
  60.                 _validatePassword();
  61.               },
  62.               onTap: () {
  63.                 _pushToTextField();
  64.               },
  65.             )
  66.             ],
  67.           ),
  68.         )
  69.       ],
  70.     );
  71.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement