class Player { final String name; final Set positions; Player({required this.name, required this.positions}); Map toMap() => { 'name': name, 'positions': positions.toList(), }; factory Player.fromMap(Map map) => Player( name: (map['name'] ?? '').toString(), positions: Set.from(map['positions'] ?? const []), ); }