class Liste {
  final String id;
  String title;
  final String owner;
  List<String> members;

  Liste({
    required this.id,
    required this.title,
    required this.owner,
    required this.members,
  });

  factory Liste.fromJson(Map<String, dynamic> json) {
    return Liste(
      id: json['id'] as String,
      title: json['title'] as String,
      owner: json['owner'] as String? ?? '',
      members: List<String>.from(json['members'] as List? ?? []),
    );
  }
}

class Item {
  final String id;
  String name;
  bool checked;
  int position;

  Item({
    required this.id,
    required this.name,
    this.checked = false,
    this.position = 0,
  });

  factory Item.fromJson(Map<String, dynamic> 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,
    );
  }
}
