You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
justMusic/Sources/justMUSIC/lib/model/mapper/UserMapper.dart

37 lines
1.1 KiB

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:justmusic/model/User.dart';
import 'package:firebase_auth/firebase_auth.dart' as firebase_auth;
import '../../main.dart';
class UserMapper {
static User? toModel(DocumentSnapshot<Map<String, dynamic>>? snapshot,
SnapshotOptions? options) {
if (snapshot == null) {
return null;
}
final data = snapshot.data();
return User(
data?["uid"],
data?["pseudo"],
data?["country"],
data?["mail"],
data?["profilePicture"],
data?["followers"] as int,
data?["nbCapsules"] as int,
data?["followed"] as int,
data?['friends'] is Iterable ? List.from(data?['friends']) : []);
}
/*
static Map<String, dynamic> toFirebase(User user) {
return {
if (user.pseudo != null) "name": u,
if (user.country != null) "state": state,
if (user.mail != null) "country": country,
if (user.pp != null) "capital": capital,
if (user.followers != null) "population": population,
if (user.capsules != null) "regions": regions,
if ()
};
}*/
}