Created
October 12, 2020 21:48
-
-
Save ptruiz/945cceb00f6862e8f1aa8206144982eb to your computer and use it in GitHub Desktop.
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
class _MyHomePageState extends State<MyHomePage> { | |
final FirebaseAuth firebaseAuth = FirebaseAuth.instance; | |
UserCredential user; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
actions: <Widget>[ | |
Builder(builder: (BuildContext context) { | |
return FlatButton( | |
child: const Text('Sign out'), | |
textColor: Theme.of(context).buttonColor, | |
onPressed: () async { | |
final User user = await firebaseAuth.currentUser; | |
if (user == null) { | |
Scaffold.of(context).showSnackBar(const SnackBar( | |
content: Text('No one has signed in.'), | |
)); | |
return; | |
} | |
signOut(); | |
}, | |
); | |
}) | |
], | |
), | |
body: Center( | |
child: Column(children: [ | |
FlatButton(onPressed: () {signInWithGitHub();}, child: Text("Sign In With GitHub")), | |
Text((user != null) ? user.user.displayName : "Not logged in"), | |
],) | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment