am tying to calling user to appear in profile page the app block when i fixed it i faced other problem which is this one if there any solution can help me
import 'package:flutter/foundation.dart';
class UserModel {
String? uid;
String? Username;
String? email;
String? photoUrl;
UserModel(
{this.uid, this.email, this.Username, this.photoUrl});
// receving data from the server
factory UserModel.fromMap(Map) {
return UserModel(
uid: Map['userId'],
Username: Map['Username'],
email: Map['email'],
photoUrl: Map['photoUrl'],
);
}
// /// sending data to firestore
Map<String, dynamic> toMap() {
return {
'userId': uid,
'Username': Username,
'email': email,
'photoUrl': photoUrl,
};
}
}
4
Answers
by using this :
you’re referring to the
Map
as it type, so it throws the error.you need to referr to a
Map
object, not theMap
type, so try this :while feting the data you need to declare the response as Map<String, dynamic>? even after doing that also if the error remains, try adding Map[‘userId].toString() || Map[‘userId] as String. refer below code
Don’t use
Map
as variable name, it is a DataTypeMake sure
is a String in your firestore