42 lines
1.1 KiB
Dart
42 lines
1.1 KiB
Dart
class Team {
|
|
final String id;
|
|
final String name;
|
|
final String season;
|
|
final String imageUrl;
|
|
final bool isFavorite;
|
|
final String createdAt;
|
|
final int playerCount; // 👇 NOVA VARIÁVEL AQUI
|
|
|
|
Team({
|
|
required this.id,
|
|
required this.name,
|
|
required this.season,
|
|
required this.imageUrl,
|
|
required this.isFavorite,
|
|
required this.createdAt,
|
|
this.playerCount = 0, // 👇 VALOR POR DEFEITO
|
|
});
|
|
|
|
factory Team.fromMap(Map<String, dynamic> map) {
|
|
return Team(
|
|
id: map['id']?.toString() ?? '',
|
|
name: map['name']?.toString() ?? 'Sem Nome',
|
|
season: map['season']?.toString() ?? '',
|
|
imageUrl: map['image_url']?.toString() ?? '',
|
|
isFavorite: map['is_favorite'] ?? false,
|
|
createdAt: map['created_at']?.toString() ?? '',
|
|
// 👇 AGORA ELE LÊ A CONTAGEM DA TUA NOVA VIEW!
|
|
playerCount: map['player_count'] != null ? int.tryParse(map['player_count'].toString()) ?? 0 : 0,
|
|
);
|
|
}
|
|
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'name': name,
|
|
'season': season,
|
|
'image_url': imageUrl,
|
|
'is_favorite': isFavorite,
|
|
};
|
|
}
|
|
} |