Advertisement
Guest User

Smartfarm registration validation [Application]

a guest
Jan 2nd, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 4.33 KB | None | 0 0
  1. <Widget>[
  2.                             Container(
  3.                               child: TextFormField(
  4.                                 controller: username,
  5.                                 decoration:
  6.                                     InputDecoration(labelText: 'Username'),
  7.                                 validator: (value) {
  8.                                   if (value.isEmpty) {
  9.                                     return 'Username cannot be empty';
  10.                                   }
  11.                                 },
  12.                               ),
  13.                             ),
  14.                             Container(
  15.                               margin: const EdgeInsets.only(top: 12),
  16.                               child: TextFormField(
  17.                                 controller: password,
  18.                                 obscureText: true,
  19.                                 decoration:
  20.                                     InputDecoration(labelText: 'Password'),
  21.                                 validator: (value) {
  22.                                   if (value.isEmpty) {
  23.                                     return 'Password cannot be empty';
  24.                                   }
  25.                                 },
  26.                               ),
  27.                             ),
  28.                             Container(
  29.                               margin: const EdgeInsets.only(top: 12),
  30.                               child: TextFormField(
  31.                                 controller: email,
  32.                                 decoration: InputDecoration(labelText: 'Email'),
  33.                                 validator: (value) {
  34.                                   RegExp emailValidator = new RegExp(
  35.                                       r'^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$');
  36.                                   if (!emailValidator.hasMatch(value)) {
  37.                                     return 'Email is invalid';
  38.                                   }
  39.                                 },
  40.                               ),
  41.                             ),
  42.                             Container(
  43.                               margin: const EdgeInsets.only(top: 12),
  44.                               child: TextFormField(
  45.                                   controller: address,
  46.                                   decoration:
  47.                                       InputDecoration(labelText: 'Address'),
  48.                                   validator: (value) {
  49.                                     if (value.isEmpty) {
  50.                                       return 'Address cannot be empty';
  51.                                     }
  52.                                   }),
  53.                             ),
  54.                             Container(
  55.                               margin: const EdgeInsets.only(top: 12),
  56.                               child: TextFormField(
  57.                                   controller: nationalID,
  58.                                   decoration:
  59.                                       InputDecoration(labelText: 'National ID'),
  60.                                   keyboardType: TextInputType.number,
  61.                                   validator: validateNationalID),
  62.                             ),
  63.                             Container(
  64.                               margin: const EdgeInsets.only(top: 12),
  65.                               child: new DropdownButton<String>(
  66.                                 items: constants.AvailableProvince.map(
  67.                                     (String value) {
  68.                                   return new DropdownMenuItem<String>(
  69.                                     value: value,
  70.                                     child: new Text(value),
  71.                                   );
  72.                                 }).toList(),
  73.                                 onChanged: (value) {
  74.                                   setState(() {
  75.                                     province = value;
  76.                                   });
  77.                                 },
  78.                                 hint: Text("Province"),
  79.                                 value: province,
  80.                                 isExpanded: true,
  81.                               ),
  82.                             ),
  83.                           ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement