Advertisement
Guest User

changing subtitle

a guest
Jul 18th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.64 KB | None | 0 0
  1. new ListTile(
  2.               title: new Text("Log In"),
  3.               leading: new Icon(Icons.account_box),
  4.               onTap: () => _signIn()
  5.                   .then((FirebaseUser user) => print(user))
  6.                   .catchError((e) => print(e)),
  7.               subtitle: StreamBuilder(
  8.                 stream: FirebaseAuth.instance.onAuthStateChanged,
  9.                 builder: (BuildContext context,
  10.                     AsyncSnapshot<FirebaseUser> snapshot) {
  11.                   if (snapshot.connectionState == ConnectionState.waiting) {
  12.                     username = 'loading';
  13.                     return Text(username);
  14.                   } else if (!snapshot.hasData) {
  15.                     username = 'you are not logged in';
  16.                     return Text(username);
  17.                   } else {
  18.                     username = snapshot.data.displayName;
  19.                     return Text(username);
  20.                   }
  21.                 },
  22.               ),
  23.             ),
  24.             new ListTile(
  25.               title: new Text("Log Out"),
  26.               leading: new Icon(Icons.account_circle),
  27.               onTap: () => _signOut(),
  28.             ),
  29. //this is the sign in code
  30.  
  31.   Future<FirebaseUser> _signIn() async {
  32.     GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
  33.     GoogleSignInAuthentication gSA = await googleSignInAccount.authentication;
  34.  
  35.     FirebaseUser user = await _auth.signInWithGoogle(
  36.         idToken: gSA.idToken, accessToken: gSA.accessToken);
  37.     print("User Name : ${user.displayName}");
  38.     return user;
  39.   }
  40. //this is the sign out code
  41.  void _signOut() {
  42.     googleSignIn.signOut();
  43.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement