This file contains 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
home: HomePage(title: 'Flutter Demo Home Page'), |
This file contains 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
body: Container( | |
padding: EdgeInsets.all(20.0), | |
child: Form( // <= NEW | |
key: _formKey, // <= NEW | |
child: Column( | |
children: <Widget>[ | |
.... | |
], | |
), | |
), |
This file contains 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
// save the fields.. | |
final form = _formKey.currentState; | |
form.save(); | |
// Validate will return true if is valid, or false if invalid. | |
if (form.validate()) { | |
print("$_email $_password"); | |
} |
This file contains 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
home: HomePage(), |
This file contains 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
void main() => runApp( | |
ChangeNotifierProvider<AuthService>( | |
child: MyApp(), | |
builder: (BuildContext context) { | |
return AuthService(); | |
}, | |
), | |
); |
This file contains 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
import 'package:flutter/material.dart'; | |
class LoginPage extends StatefulWidget { | |
@override | |
_LoginPageState createState() => _LoginPageState(); | |
} | |
class _LoginPageState extends State<LoginPage> { | |
@override | |
Widget build(BuildContext context) { |
This file contains 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
body: Container( | |
padding: EdgeInsets.all(20.0), | |
child: Column( | |
children: <Widget>[ | |
Text( | |
'Login Information', | |
style: TextStyle(fontSize: 20), | |
), | |
TextFormField( | |
keyboardType: TextInputType.emailAddress, |
This file contains 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
import 'package:firebase_auth/firebase_auth.dart'; | |
import 'dart:async'; | |
class AuthService { | |
final FirebaseAuth _auth = FirebaseAuth.instance; | |
// return the Future with firebase user if one exists | |
Future get getUser => _auth.currentUser(); | |
// wrapping the firebase calls |
This file contains 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
import 'home_page.dart'; |
This file contains 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
TextFormField( | |
onSaved: (value) => _email = value, // <= NEW | |
keyboardType: TextInputType.emailAddress, | |
decoration: InputDecoration(labelText: "Email Address")), | |
TextFormField( | |
onSaved: (value) => _password = value, // <= NEW | |
obscureText: true, | |
decoration: InputDecoration(labelText: "Password")), |