add name to team
Some checks failed
Pull Request Pipeline / lint (pull_request) Successful in 2m8s
Pull Request Pipeline / test (pull_request) Failing after 1m56s

This commit is contained in:
gelbeinhalb
2026-01-19 15:46:25 +01:00
parent c97fdc2b5f
commit 8dd2f5f8b8
2 changed files with 9 additions and 3 deletions

View File

@@ -4,11 +4,13 @@ import 'package:uuid/uuid.dart';
class Team {
final String id;
final String name;
final DateTime createdAt;
final List<Player> members;
Team({
String? id,
required this.name,
DateTime? createdAt,
required this.members,
}) : id = id ?? const Uuid().v4(),
@@ -16,12 +18,13 @@ class Team {
@override
String toString() {
return 'Team{id: $id, members: $members}';
return 'Team{id: $id, name: $name, members: $members}';
}
/// Creates a Team instance from a JSON object.
Team.fromJson(Map<String, dynamic> json)
: id = json['id'],
name = json['name'],
createdAt = DateTime.parse(json['createdAt']),
members = (json['members'] as List)
.map((memberJson) => Player.fromJson(memberJson))
@@ -30,6 +33,7 @@ class Team {
/// Converts the Team instance to a JSON object.
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'createdAt': createdAt.toIso8601String(),
'members': members.map((member) => member.toJson()).toList(),
};