import 'dart:convert'; import '../models/plex/plex_home_user.dart'; List> encodePlexHomeUsersCache(List users) { return users.map((user) => user.toJson()).toList(growable: false); } String encodePlexHomeUsersCacheJson(List users) { return jsonEncode(encodePlexHomeUsersCache(users)); } List decodePlexHomeUsersCache(String raw) { final decoded = jsonDecode(raw); if (decoded is! List) { throw const FormatException('Plex Home users cache is not a list'); } return decoded.whereType>().map(PlexHomeUser.fromJson).toList(growable: false); }