Skip to content

Instantly share code, notes, and snippets.

@ptruiz
Created October 12, 2020 21:48
Show Gist options
  • Save ptruiz/945cceb00f6862e8f1aa8206144982eb to your computer and use it in GitHub Desktop.
Save ptruiz/945cceb00f6862e8f1aa8206144982eb to your computer and use it in GitHub Desktop.
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