Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LoginPage extends StatefulWidget {
- @override
- State<StatefulWidget> createState() {
- return _LoginPageState();
- }
- }
- class _LoginPageState extends State<LoginPage> {
- final _formKey = GlobalKey<FormState>();
- String _email;
- String _password;
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text("Login Page Flutter Firebase"),
- ),
- body: Container(
- padding: EdgeInsets.all(20.0),
- child: Column(
- children: <Widget>[
- Spacer(flex: 5),
- Text(
- "Login Information",
- style: new TextStyle(fontSize: 30.0),
- ),
- Spacer(
- flex: 5,
- ),
- TextFormField(
- key: _formKey,
- onSaved: (value) => _email = value,
- keyboardType: TextInputType.emailAddress,
- decoration: InputDecoration(labelText: "Email Address"),
- ),
- TextFormField(
- onSaved: (value) => _password = value,
- obscureText: true,
- decoration: InputDecoration(labelText: "Password"),
- ),
- Spacer(flex: 3),
- RaisedButton(
- child: Text("Login"),
- onPressed: () async {
- //Getting the error here
- final form = _formKey.currentState;
- form.save();
- if (form.validate()) {
- print('$_email $_password');
- var result = await
- Provider.of<AuthService(context).loginUser(email: _email, password:_password);
- if (result == null) {
- print("result is null");
- }
- }
- }),
- Spacer(
- flex: 20,
- )
- ],
- ),
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement