Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created June 4, 2019 17:52
Show Gist options
  • Save aaronksaunders/609b7c41167b96e4ef03e1ac982b2fe8 to your computer and use it in GitHub Desktop.
Save aaronksaunders/609b7c41167b96e4ef03e1ac982b2fe8 to your computer and use it in GitHub Desktop.
Markdium-Simple Firebase Login Flow in Flutter, Now Firebase
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(primarySwatch: Colors.blue),
home: FutureBuilder(
future: Provider.of(context).getUser(),
builder: (context, AsyncSnapshot snapshot) { // ⇐ NEW
if (snapshot.connectionState == ConnectionState.done) {
// log error to console ⇐ NEW
if (snapshot.error != null) {
print("error");
return Text(snapshot.error.toString());
}
// redirect to the proper page, pass the user into the
// `HomePage` so we can display the user email in welcome msg ⇐ NEW
return snapshot.hasData ? HomePage(snapshot.data) : LoginPage();
} else {
// show loading indicator ⇐ NEW
return LoadingCircle();
}
},
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment