flutter_profile/lib/src/models/user.dart

56 lines
1.3 KiB
Dart
Raw Normal View History

2022-08-26 15:31:42 +02:00
import 'dart:typed_data';
import 'package:flutter/material.dart';
2022-09-20 14:11:38 +02:00
/// User is used to contain all user data. It consists of three standard fields: firstName, lastName and image.
///
/// For additional data profileData can be used.
class User {
2022-08-26 15:31:42 +02:00
String? firstName;
String? lastName;
Uint8List? image;
ProfileData? profileData;
2022-08-26 15:31:42 +02:00
User(
this.firstName,
this.lastName,
this.image,
this.profileData,
);
factory User.fromMap(Map<String, dynamic> data) {
return User(
data['firstName'],
data['lastName'],
data['image'],
data['profileData'],
);
}
Map<String, dynamic> toMap() {
return {
'firstName': firstName,
'lastName': lastName,
'image': image,
'profileData': profileData,
};
}
}
2022-09-20 14:11:38 +02:00
/// ProfileData is used to store custom/addintional data for a user.
///
2022-09-20 14:11:38 +02:00
/// The MapWidget method is used to bind a [Widget] to one of the keys. This will override the standard textfield.
///
2022-09-20 14:11:38 +02:00
/// The Builditems method is used to make the list of field to house the user data.
2022-08-26 15:31:42 +02:00
abstract class ProfileData {
const ProfileData();
ProfileData fromMap(Map<String, dynamic> data);
Map<String, dynamic> toMap();
Map<String, dynamic> mapWidget(VoidCallback update, BuildContext context);
2022-08-26 15:31:42 +02:00
ProfileData create();
}