Add view and logik
This commit is contained in:
48
lib/models/user_model.dart
Normal file
48
lib/models/user_model.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'dart:convert';
|
||||
|
||||
class UserModel {
|
||||
final String uuid;
|
||||
final String username;
|
||||
final String passwort;
|
||||
UserModel({
|
||||
required this.uuid,
|
||||
required this.username,
|
||||
required this.passwort,
|
||||
});
|
||||
|
||||
UserModel copyWith({
|
||||
String? uuid,
|
||||
String? username,
|
||||
String? passwort,
|
||||
}) {
|
||||
return UserModel(
|
||||
uuid: uuid ?? this.uuid,
|
||||
username: username ?? this.username,
|
||||
passwort: passwort ?? this.passwort,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return <String, dynamic>{
|
||||
'pk_userUuid': uuid,
|
||||
'benutzer': username,
|
||||
'kennwort': passwort,
|
||||
};
|
||||
}
|
||||
|
||||
factory UserModel.fromMap(Map<String, dynamic> map) {
|
||||
return UserModel(
|
||||
uuid: map['pk_userUuid'] as String,
|
||||
username: map['benutzer'] as String,
|
||||
passwort: map['kennwort'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory UserModel.fromJson(String source) => UserModel.fromMap(json.decode(source) as Map<String, dynamic>);
|
||||
|
||||
@override
|
||||
String toString() => 'UserModel(uuid: $uuid, username: $username, passwort: $passwort)';
|
||||
}
|
||||
Reference in New Issue
Block a user