update y uso de provider

This commit is contained in:
Felipe
2023-10-30 10:25:46 -05:00
parent efa8c37a88
commit 7c902696b6
7 changed files with 256 additions and 183 deletions
+24
View File
@@ -37,6 +37,30 @@ class UserModel {
}
}
@override
String toString() {
return 'UserModel(name: $name, city: $city, profession: $profession, state: $state, tarifa: $tarifa, phoneNumber: $phoneNumber, token: $token)';
}
static UserModel fromFirestore(Map<String, dynamic> firestoreMap) {
try {
String? avatar = firestoreMap['photo'];
return UserModel(
firestoreMap['name'] ?? 'Sin nombre',
firestoreMap['city'] ?? 'Sin ciudad',
firestoreMap['profesion'],
firestoreMap['estado'],
avatar != null ? storage.ref().child(avatar) : null,
firestoreMap['tarifa'] ?? 0,
firestoreMap['phoneNumber'] ?? 'Sin numero',
firestoreMap['token'],
);
} catch (e) {
print('DesdeProvider $e');
return UserModel('', '', '', null, null, 0, '', '');
}
}
static Future<UserModel> getUser(String uid) async {
try {
final snapshot =