My app uses Firebase Auth. I started off of a template. I added three extra fields to the User object. I have to make sure that these fields (xp, level, session_id) are initialized if they are not set yet. So I need 1. access the fields, 2. optionally update them. After both cases I plan to load the values into app state variables and later when they change I'd need to update the user fields.
How to access and update custom Firebase User fields in custom action?
Custom Code
I tried to search numerous community and StackOverflow posts. I assume that there should be some simple way to access these variables since FlutterFlow is very cozy with Firebase auth and this must be a very common use-case. However I'm even stuck at the access part, let alone the update. I thought that this will be straight forward.
Closest I got maybe is, however this will get me only to a generic (non typed) document reference. Isn't there some accessible variable which already has what I want, since these values are accessible from widgets?
import '/auth/firebase_auth/auth_util.dart' as auth_util;
final userRef = auth_util.currentUserReference;
// TODO: I need to weight lift somehow to even get to the User class
// (if there's anything like that).
// Then it's a question if that class will only have the standard fields or my extra fields as well
// And then I'd need to update the "document" = user as well once the custom fields are initialized
Yes
9 replies