Renamed folder to "models"

This commit is contained in:
2026-04-08 22:27:50 +02:00
parent 14d46d7e52
commit ad6d08374e
46 changed files with 795 additions and 569 deletions

View File

@@ -0,0 +1,38 @@
import 'package:clock/clock.dart';
import 'package:uuid/uuid.dart';
class Player {
final String id;
final DateTime createdAt;
final String name;
final String description;
Player({
String? id,
DateTime? createdAt,
required this.name,
String? description,
}) : id = id ?? const Uuid().v4(),
createdAt = createdAt ?? clock.now(),
description = description ?? '';
@override
String toString() {
return 'Player{id: $id, name: $name, description: $description}';
}
/// Creates a Player instance from a JSON object.
Player.fromJson(Map<String, dynamic> json)
: id = json['id'],
createdAt = DateTime.parse(json['createdAt']),
name = json['name'],
description = json['description'];
/// Converts the Player instance to a JSON object.
Map<String, dynamic> toJson() => {
'id': id,
'createdAt': createdAt.toIso8601String(),
'name': name,
'description': description,
};
}