Open Shivansh-yadav13 opened 1 year ago
Did you find any alternative how to do it?
value.isEmpty can be replaced with =>> value == null / value.isNull But how to resolve other issue?
Use below code to resolve the issue. If you are getting an error in the TextFormField validator, your condition should be : validator: (value) { if (value ==null || value.isEmpty) { return "Username cannot be empty"; }
Similar in both username and password.
And in the moveToHome() method validation condition should be: if(_formkey.currentState!.validate()){};
`validator: (value) { if (value != null && value.isEmpty) { return "Username cannot be empty"; }
return null;
}`
`moveToHome(BuildContext context) async { if (formKey.currentState != null && formKey.currentState!.validate()) { setState(() { change = true; });
await Future.delayed(const Duration(seconds: 1));
await Navigator.pushNamed(context, AllRoutes.homeRoute);
setState(() {
//rendering again on coming back
change = false;
});
}
}`
https://github.com/iampawan/30DaysOfFlutter/blob/e7578cffb012838d1051c85b0766169821e918a0/lib/pages/login_page.dart#L65
This does not work anymore, it gives an error
Similarly,
https://github.com/iampawan/30DaysOfFlutter/blob/e7578cffb012838d1051c85b0766169821e918a0/lib/pages/login_page.dart#L16
This also give error