FirebaseUser loggedinuser;
FirebaseAuth _auth = FirebaseAuth.instance;
Future<void> currentUser()async
{
try
{
FirebaseUser user = await _auth.currentUser();
if(user != null)
{
setState(() {
loggedinuser = user;
});
}
}
catch(e){
print(e);
}
}
@override
void initState() {
super.initState();
currentUser();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Logged in"),
centerTitle: true,
backgroundColor: Colors.green,
),
body: Container(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 20,vertical: 20),
child: Text(loggedinuser.providerId)
Hi im new in FLutter and was working on a little project to practice but whenever i try to show name of user i get an error saying that Text widget cant be null but im initializing the loggedinuser by using setState i can see email but not the name on screen Would appreciate the help