I'm working with Flutter/Dart and Firebase. I'm using provider to grab Firebase user info and I'm seeing this error:
The class 'User' doesn't have a default constructor.
Try using one of the named constructors defined in 'User'.
The code causing the issue is:
providers: [
ChangeNotifierProvider<AuthProvider>(create: (_) => AuthProvider()),
StreamProvider<User>.value(
initialData: User(
name: 'Friend',
uid: '0',
),
value: FirebaseAuth.instance.authStateChanges(),
// initialData: ,
),
I don't have a user class. The User class is coming from Firebase so how could I possibly add a constructor to it? Is there a way to get around this constructor error in the initialData field?
There's a UserInfo class that has a constructor. But, when I try using that, I can't set any default values for the fields. I'm getting The named parameter 'uid' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'uid'