Issue
I have been working with google sign in and I need to display the email but I can not get set state working can someone pls help!
Here is my current code:
const Padding(
padding: EdgeInsets.fromLTRB(9, 0, 9, 0),
child: SignInButton(),
),
Text(userEmail ?? 'email') // i need the email to update when i sign in
],
),
);
}
}
final _auth = FirebaseAuth.instance;
dynamic? user;
String? userEmail;
String? userPhoneNumber;
void getCurrentUserInfo() async {
user = await _auth.currentUser!;
userEmail = user.email;
userPhoneNumber = user.phoneNumber;
}
Solution
void getCurrentUserInfo() async {
user = await _auth.currentUser!;
userEmail = user.email;
userPhoneNumber = user.phoneNumber;
setState((){})
}
assuming you are in a stateful widget. Just add setState()
in getCurrentUserInfo
and it should update the widget.
Answered By – amo
Answer Checked By – Mildred Charles (FlutterFixes Admin)