Yes you are right that it requires some if else statement.
I think you are looking for auth.currentUser() function to check the state of the signin and singout of the user.
The following code checks the user signin status and if the user is signned in then places the user profile photo.
FirebaseAuth auth; //firebase auth
FirebaseUser user; // firebase user
var imageUrl = "assets/image.png"; //you can use a image
//as a default image that would be replaced later with the profile photo
Widget userProfilePhoto()
{
return Center(
child: Container(
height: 100.0,
width: 100.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
fit : BoxFit.fill,
image: NetworkImage(userurl)
)
),
)
),
}
void checkUser()
{
//Check if the user is signned in or not with the currentUser() function
if(auth.currentUser() != null)
{
setState((){
userImageUrl = user.photoUrl;
//if the user is signned in then set the url to be the image url
});
}
else
{
//call signin method to make the user signin
signIn();
}
}