Files

30 lines
682 B
Dart
Raw Permalink Normal View History

class Pack {
final int? id;
final String nombre;
final String icono;
final List<String> tags;
Pack({
this.id,
required this.nombre,
this.icono = '📦',
required this.tags,
});
factory Pack.fromMap(Map<String, dynamic> map) => Pack(
id: map['id'] as int?,
nombre: map['nombre'] as String,
icono: map['icono'] as String? ?? '📦',
tags: (map['tags'] as String).split(',').where((t) => t.isNotEmpty).toList(),
);
Map<String, dynamic> toMap() => {
if (id != null) 'id': id,
'nombre': nombre,
'icono': icono,
'tags': tags.join(','),
};
int get tagCount => tags.length;
}