Home > Back-end >  Can I make the background a different colour based on the currently signed in user on flutter using
Can I make the background a different colour based on the currently signed in user on flutter using

Time:05-21

I'm making an app where I want each signed in user to see something different that is unique to them. I'm using firebase and I've been able to get a user to log in to their account but I don't know now how to check that for example if bob is signed in, the background is pink, if sally is signed in, the background is blue. I'm not sure how to say if User = specificuid then do something.

eg

If current user = oneuserID {
backgroundColor: Colors.pink,
}

else if current user = anotheruserID {
backgroundColor: Colors.white,
}

Thanks!

CodePudding user response:

Try doing like this, When the user signed up, store a unique color in firebase database, and whenever the user signs back in, fetch the color and set it as background color, lemme know if you need any help with code.

CodePudding user response:

During your authentication process you receive the current user.

This user gives you the unique user-id.

var uid = FirebaseAuth.instance.currentUser.uid
if(uid == 'rif2t3gudugt...') {
  ...
}

But this makes only sense if you know all user-ids and the amount of users is very limited.

Otherwise, store the user specific color in Firestore and access that color after the user logged in.

  • Related