I'm trying to use (profileId: currentUser.id)
in:
body: PageView(
children: <Widget>[
//Feed(),
ElevatedButton(
child: Text('Cerrar sesión'),
onPressed: logout,
),
SubirPost(currentUser: currentUser),
EditarPerfil(profileId: currentUser.id),
],
controller: pageController,
onPageChanged: onPageChanged,
physics: NeverScrollableScrollPhysics(),
),
but it gives me this error:
The property 'id' can't be unconditionally accessed because the receiver can be 'null'.
Try making the access conditional (using '?.') or adding a null check to the target ('!').
I've already tried with the null check ( like this: profileId: currentUser!.id
)but when I debug it throws a Null check operator used on a null value
error
id is declared like this on a user model file:
class User {
final String id;
final String username;
final String email;
final String photoUrl;
final String displayName;
final String bio;
User(
{required this.id,
required this.username,
required this.email,
required this.photoUrl,
required this.displayName,
required this.bio});
factory User.fromDocument(DocumentSnapshot doc) {
return User(
id: doc['id'],
email: doc['email'],
username: doc['username'],
photoUrl: doc['photoUrl'],
displayName: doc['displayName'],
bio: doc['bio'],
);}}
for profileId is this on another file:
final String profileId;
EditarPerfil({required this.profileId});
I've tried everything I've found
Also, when I try to use ?
on the user model final String id
I get the error The argument type 'String?' can't be assigned to the parameter type 'String'
Same with the final String profileId
I'm importing the cloud_firestore
, firebase_storage
and google_sign_in
packages.