Created
June 4, 2019 17:52
-
-
Save aaronksaunders/609b7c41167b96e4ef03e1ac982b2fe8 to your computer and use it in GitHub Desktop.
Markdium-Simple Firebase Login Flow in Flutter, Now Firebase
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
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