update user model
This commit is contained in:
@@ -23,7 +23,7 @@ OwnUser _$OwnUserFromJson(Map<String, dynamic> json) {
|
|||||||
.toList() ??
|
.toList() ??
|
||||||
[],
|
[],
|
||||||
id: json['id'] as String,
|
id: json['id'] as String,
|
||||||
role: json['role'] as String? ?? '',
|
role: json['role'] as String,
|
||||||
createdAt: json['created_at'] == null
|
createdAt: json['created_at'] == null
|
||||||
? null
|
? null
|
||||||
: DateTime.parse(json['created_at'] as String),
|
: DateTime.parse(json['created_at'] as String),
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ part 'user.g.dart';
|
|||||||
class User {
|
class User {
|
||||||
/// Constructor used for json serialization
|
/// Constructor used for json serialization
|
||||||
User({
|
User({
|
||||||
this.id = '',
|
required this.id,
|
||||||
this.role = '',
|
this.role,
|
||||||
DateTime? createdAt,
|
DateTime? createdAt,
|
||||||
DateTime? updatedAt,
|
DateTime? updatedAt,
|
||||||
this.lastActive,
|
this.lastActive,
|
||||||
@@ -24,18 +24,6 @@ class User {
|
|||||||
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(
|
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(
|
||||||
Serialization.moveToExtraDataFromRoot(json, topLevelFields));
|
Serialization.moveToExtraDataFromRoot(json, topLevelFields));
|
||||||
|
|
||||||
/// Use this named constructor to create a new user instance
|
|
||||||
User.init(
|
|
||||||
this.id, {
|
|
||||||
this.online = false,
|
|
||||||
this.extraData = const {},
|
|
||||||
required this.createdAt,
|
|
||||||
required this.updatedAt,
|
|
||||||
this.teams = const [],
|
|
||||||
required this.role,
|
|
||||||
}) : lastActive = null,
|
|
||||||
banned = false;
|
|
||||||
|
|
||||||
/// Known top level fields.
|
/// Known top level fields.
|
||||||
/// Useful for [Serialization] methods.
|
/// Useful for [Serialization] methods.
|
||||||
static const topLevelFields = [
|
static const topLevelFields = [
|
||||||
@@ -53,9 +41,8 @@ class User {
|
|||||||
final String id;
|
final String id;
|
||||||
|
|
||||||
/// User role
|
/// User role
|
||||||
@JsonKey(
|
@JsonKey(includeIfNull: false, toJson: Serialization.readOnly)
|
||||||
includeIfNull: false, toJson: Serialization.readOnly, defaultValue: '')
|
final String? role;
|
||||||
final String role;
|
|
||||||
|
|
||||||
/// User role
|
/// User role
|
||||||
@JsonKey(
|
@JsonKey(
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ part of 'user.dart';
|
|||||||
User _$UserFromJson(Map<String, dynamic> json) {
|
User _$UserFromJson(Map<String, dynamic> json) {
|
||||||
return User(
|
return User(
|
||||||
id: json['id'] as String,
|
id: json['id'] as String,
|
||||||
role: json['role'] as String? ?? '',
|
role: json['role'] as String?,
|
||||||
createdAt: json['created_at'] == null
|
createdAt: json['created_at'] == null
|
||||||
? null
|
? null
|
||||||
: DateTime.parse(json['created_at'] as String),
|
: DateTime.parse(json['created_at'] as String),
|
||||||
|
|||||||
Reference in New Issue
Block a user