Created
June 23, 2019 21:25
-
-
Save timbergus/a6b20004e662c8015e1a0cf24c99dfd3 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
// Logged status. | |
bool isLogged = false; | |
// Firebase authentication instance. | |
FirebaseAuth _auth = FirebaseAuth.instance; | |
// The init state will check the logged status of the user. | |
@override | |
void initState() { | |
super.initState(); | |
_auth.currentUser().then((response) { | |
if (response != null) { | |
setState(() { | |
isLogged = true; | |
}); | |
} | |
}); | |
} | |
// The login button will login to the app using | |
// the user credentials, and sets the logged status | |
// to true. | |
RaisedButton( | |
child: Text( | |
'Login', | |
), | |
color: Colors.blue[400], | |
onPressed: () async { | |
await _auth.signInWithEmailAndPassword( | |
email: '[email protected]', | |
password: 'password', | |
); | |
setState(() { | |
isLogged = true; | |
}); | |
} | |
), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment