class PermissionModel {
  final String title;
  final List<PermissionAttributes> subOptions;

  PermissionModel({required this.title, required this.subOptions});

  factory PermissionModel.fromJson(Map<String, dynamic> json) {
    return PermissionModel(
      title: json['title'],
      subOptions: (json['subOptions'] as List)
          .map((e) => PermissionAttributes.fromJson(e))
          .toList(),
    );
  }

  static List<PermissionModel> fromJsonList(List<dynamic> jsonList) {
    return jsonList.map((json) => PermissionModel.fromJson(json)).toList();
  }
}

class PermissionAttributes {
  final String title;
  final List<PermissionAttributes>? subOptions;
  final bool? isChecked;

  PermissionAttributes({required this.title, this.subOptions, this.isChecked});

  factory PermissionAttributes.fromJson(Map<String, dynamic> json) {
    return PermissionAttributes(
      title: json['title'],
      isChecked: json['isChecked'],
      subOptions: json['subOptions'] != null
          ? (json['subOptions'] as List)
              .map((e) => PermissionAttributes.fromJson(e))
              .toList()
          : null,
    );
  }
}
