@@ -3,9 +3,11 @@ import 'dart:io';
3
3
4
4
import 'package:cached_network_image/cached_network_image.dart' ;
5
5
import 'package:cloud_firestore/cloud_firestore.dart' ;
6
+ import 'package:firebase_auth/firebase_auth.dart' ;
6
7
import 'package:flutter/material.dart' ;
7
8
import 'package:flutter_chat_demo/chat.dart' ;
8
9
import 'package:flutter_chat_demo/const.dart' ;
10
+ import 'package:flutter_chat_demo/login.dart' ;
9
11
import 'package:flutter_chat_demo/settings.dart' ;
10
12
import 'package:google_sign_in/google_sign_in.dart' ;
11
13
@@ -39,7 +41,8 @@ class MainScreenState extends State<MainScreen> {
39
41
context: context,
40
42
builder: (BuildContext context) {
41
43
return SimpleDialog (
42
- contentPadding: EdgeInsets .only (left: 0.0 , right: 0.0 , top: 0.0 , bottom: 0.0 ),
44
+ contentPadding:
45
+ EdgeInsets .only (left: 0.0 , right: 0.0 , top: 0.0 , bottom: 0.0 ),
43
46
children: < Widget > [
44
47
Container (
45
48
color: themeColor,
@@ -58,7 +61,10 @@ class MainScreenState extends State<MainScreen> {
58
61
),
59
62
Text (
60
63
'Exit app' ,
61
- style: TextStyle (color: Colors .white, fontSize: 18.0 , fontWeight: FontWeight .bold),
64
+ style: TextStyle (
65
+ color: Colors .white,
66
+ fontSize: 18.0 ,
67
+ fontWeight: FontWeight .bold),
62
68
),
63
69
Text (
64
70
'Are you sure to exit app?' ,
@@ -82,7 +88,8 @@ class MainScreenState extends State<MainScreen> {
82
88
),
83
89
Text (
84
90
'CANCEL' ,
85
- style: TextStyle (color: primaryColor, fontWeight: FontWeight .bold),
91
+ style: TextStyle (
92
+ color: primaryColor, fontWeight: FontWeight .bold),
86
93
)
87
94
],
88
95
),
@@ -102,7 +109,8 @@ class MainScreenState extends State<MainScreen> {
102
109
),
103
110
Text (
104
111
'YES' ,
105
- style: TextStyle (color: primaryColor, fontWeight: FontWeight .bold),
112
+ style: TextStyle (
113
+ color: primaryColor, fontWeight: FontWeight .bold),
106
114
)
107
115
],
108
116
),
@@ -183,7 +191,8 @@ class MainScreenState extends State<MainScreen> {
183
191
},
184
192
color: greyColor2,
185
193
padding: EdgeInsets .fromLTRB (25.0 , 10.0 , 25.0 , 10.0 ),
186
- shape: RoundedRectangleBorder (borderRadius: BorderRadius .circular (10.0 )),
194
+ shape:
195
+ RoundedRectangleBorder (borderRadius: BorderRadius .circular (10.0 )),
187
196
),
188
197
margin: EdgeInsets .only (bottom: 10.0 , left: 5.0 , right: 5.0 ),
189
198
);
@@ -196,19 +205,27 @@ class MainScreenState extends State<MainScreen> {
196
205
if (choice.title == 'Log out' ) {
197
206
handleSignOut ();
198
207
} else {
199
- Navigator .push (context, MaterialPageRoute (builder: (context) => Settings ()));
208
+ Navigator .push (
209
+ context, MaterialPageRoute (builder: (context) => Settings ()));
200
210
}
201
211
}
202
212
203
213
Future <Null > handleSignOut () async {
204
214
this .setState (() {
205
215
isLoading = true ;
206
216
});
217
+
218
+ await FirebaseAuth .instance.signOut ();
219
+ await googleSignIn.disconnect ();
207
220
await googleSignIn.signOut ();
221
+
208
222
this .setState (() {
209
223
isLoading = false ;
210
224
});
211
- Navigator .pop (context);
225
+
226
+ Navigator .of (context).pushAndRemoveUntil (
227
+ MaterialPageRoute (builder: (context) => MyApp ()),
228
+ (Route <dynamic > route) => false );
212
229
}
213
230
214
231
@override
@@ -264,7 +281,8 @@ class MainScreenState extends State<MainScreen> {
264
281
} else {
265
282
return ListView .builder (
266
283
padding: EdgeInsets .all (10.0 ),
267
- itemBuilder: (context, index) => buildItem (context, snapshot.data.documents[index]),
284
+ itemBuilder: (context, index) =>
285
+ buildItem (context, snapshot.data.documents[index]),
268
286
itemCount: snapshot.data.documents.length,
269
287
);
270
288
}
@@ -277,7 +295,9 @@ class MainScreenState extends State<MainScreen> {
277
295
child: isLoading
278
296
? Container (
279
297
child: Center (
280
- child: CircularProgressIndicator (valueColor: AlwaysStoppedAnimation <Color >(themeColor)),
298
+ child: CircularProgressIndicator (
299
+ valueColor:
300
+ AlwaysStoppedAnimation <Color >(themeColor)),
281
301
),
282
302
color: Colors .white.withOpacity (0.8 ),
283
303
)
0 commit comments