class Liste { final String id; String title; final String owner; List members; String? layoutId; Liste({ required this.id, required this.title, required this.owner, required this.members, this.layoutId, }); factory Liste.fromJson(Map json) { return Liste( id: json['id'] as String, title: json['title'] as String, owner: json['owner'] as String? ?? '', members: List.from(json['members'] as List? ?? []), layoutId: json['layout'] as String?, ); } } class Item { final String id; String name; bool checked; int position; String? sectionId; Item({ required this.id, required this.name, this.checked = false, this.position = 0, this.sectionId, }); factory Item.fromJson(Map json) { return Item( id: json['id'] as String, name: json['name'] as String, checked: json['checked'] as bool? ?? false, position: (json['position'] is int) ? json['position'] : int.tryParse(json['position'].toString()) ?? 0, sectionId: json['section'] as String?, ); } } class StoreLayout { final String id; String name; String owner; double? latitude; double? longitude; String? address; bool isPublic; StoreLayout({ required this.id, required this.name, required this.owner, this.latitude, this.longitude, this.address, this.isPublic = false, }); factory StoreLayout.fromJson(Map json) { double? parseCoord(dynamic value) { if (value == null) return null; if (value is double) return value; if (value is int) return value.toDouble(); return double.tryParse(value.toString()); } return StoreLayout( id: json['id'] as String, name: json['name'] as String? ?? '', owner: json['owner'] as String? ?? '', latitude: parseCoord(json['latitude']), longitude: parseCoord(json['longitude']), address: json['address'] as String?, isPublic: json['isPublic'] as bool? ?? false, ); } } class StoreSection { final String id; final String layoutId; String name; int position; StoreSection({ required this.id, required this.layoutId, required this.name, this.position = 0, }); factory StoreSection.fromJson(Map json) { int parsePosition(dynamic value) { if (value is int) return value; return int.tryParse(value.toString()) ?? 0; } return StoreSection( id: json['id'] as String, layoutId: json['layout'] as String? ?? '', name: json['name'] as String? ?? '', position: parsePosition(json['position']), ); } }