@@ -33,9 +33,8 @@ Future<Null> _ensureLoggedIn(BuildContext context) async {
33
33
user = await googleSignIn.signInSilently ();
34
34
}
35
35
if (user == null ) {
36
- await googleSignIn.signIn ().then ((_) {
37
- tryCreateUserRecord (context);
38
- });
36
+ await googleSignIn.signIn ();
37
+ await tryCreateUserRecord (context);
39
38
}
40
39
41
40
if (await auth.currentUser () == null ) {
@@ -58,9 +57,8 @@ Future<Null> _silentLogin(BuildContext context) async {
58
57
GoogleSignInAccount user = googleSignIn.currentUser;
59
58
60
59
if (user == null ) {
61
- user = await googleSignIn.signInSilently ().then ((_) {
62
- tryCreateUserRecord (context);
63
- });
60
+ user = await googleSignIn.signInSilently ();
61
+ await tryCreateUserRecord (context);
64
62
}
65
63
66
64
if (await auth.currentUser () == null && user != null ) {
@@ -105,7 +103,7 @@ Future<Null> _setUpNotifications() async {
105
103
}
106
104
}
107
105
108
- tryCreateUserRecord (BuildContext context) async {
106
+ Future < void > tryCreateUserRecord (BuildContext context) async {
109
107
GoogleSignInAccount user = googleSignIn.currentUser;
110
108
if (user == null ) {
111
109
return null ;
@@ -116,7 +114,6 @@ tryCreateUserRecord(BuildContext context) async {
116
114
117
115
String userName = await Navigator .push (
118
116
context,
119
- // We'll create the SelectionScreen in the next step!
120
117
new MaterialPageRoute (
121
118
builder: (context) => new Center (
122
119
child: new Scaffold (
@@ -154,6 +151,7 @@ tryCreateUserRecord(BuildContext context) async {
154
151
}
155
152
156
153
currentUserModel = new User .fromDocument (userRecord);
154
+ return null ;
157
155
}
158
156
159
157
class Fluttergram extends StatelessWidget {
@@ -233,7 +231,7 @@ class _HomePageState extends State<HomePage> {
233
231
setUpNotifications ();
234
232
}
235
233
236
- return googleSignIn.currentUser == null
234
+ return ( googleSignIn.currentUser == null || currentUserModel == null )
237
235
? buildLoginPage ()
238
236
: new Scaffold (
239
237
body: new PageView (
0 commit comments