Last active
April 24, 2020 12:34
-
-
Save itskgore/28317bd7d5c4c88ca591b80baba9abe1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Function to be called after submitting the form. | |
final _formKey = GlobalKey<FormState>(); | |
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); | |
Map<String, String> _authData22 = { | |
'username': '', | |
}; | |
Future<void> _submit(BuildContext context) async { | |
if (!_formKey.currentState.validate()) { | |
// Invalid! test | |
return; | |
} | |
_formKey.currentState.save(); | |
setState(() { | |
isLoading = true; | |
}); | |
final data = await Provider.of<Auth>(context, listen: false) | |
.login(_authData22['username']); | |
setState(() { | |
isLoading = false; | |
}); | |
if (data) { | |
Navigator.pushReplacement(context, FadeNavigation(widget: HomeScreen())); | |
} else { | |
final snackBar = new SnackBar( | |
content: new Text('Invalid Username'), | |
action: new SnackBarAction( | |
label: 'OK', | |
onPressed: () async {}, | |
), | |
duration: new Duration(seconds: 3), | |
); | |
_scaffoldKey.currentState.showSnackBar(snackBar); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment