Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. class LoginPage extends StatefulWidget {
  2. @override
  3. State<StatefulWidget> createState() {
  4. return _LoginPageState();
  5. }
  6. }
  7.  
  8. class _LoginPageState extends State<LoginPage> {
  9. final _formKey = GlobalKey<FormState>();
  10. String _email;
  11. String _password;
  12.  
  13. @override
  14. Widget build(BuildContext context) {
  15. return Scaffold(
  16. appBar: AppBar(
  17. title: Text("Login Page Flutter Firebase"),
  18. ),
  19. body: Container(
  20. padding: EdgeInsets.all(20.0),
  21. child: Column(
  22. children: <Widget>[
  23. Spacer(flex: 5),
  24. Text(
  25. "Login Information",
  26. style: new TextStyle(fontSize: 30.0),
  27. ),
  28. Spacer(
  29. flex: 5,
  30. ),
  31. TextFormField(
  32. key: _formKey,
  33. onSaved: (value) => _email = value,
  34. keyboardType: TextInputType.emailAddress,
  35. decoration: InputDecoration(labelText: "Email Address"),
  36. ),
  37. TextFormField(
  38. onSaved: (value) => _password = value,
  39. obscureText: true,
  40. decoration: InputDecoration(labelText: "Password"),
  41. ),
  42. Spacer(flex: 3),
  43. RaisedButton(
  44. child: Text("Login"),
  45. onPressed: () async {
  46. //Getting the error here
  47. final form = _formKey.currentState;
  48. form.save();
  49.  
  50. if (form.validate()) {
  51. print('$_email $_password');
  52. var result = await
  53. Provider.of<AuthService(context).loginUser(email: _email, password:_password);
  54. if (result == null) {
  55. print("result is null");
  56. }
  57. }
  58. }),
  59. Spacer(
  60. flex: 20,
  61. )
  62. ],
  63. ),
  64. ));
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement