import 'package:flutter/material.dart'; class Apply { int? relation; String? applicant, recipient, hello, createdAt; String? groupChatId; Map? setting; Apply.fromJson(Map json) { relation = json['relation']; applicant = json['applicant']; recipient = json['recipient']; hello = json['hello']; createdAt = json['createdAt']; groupChatId = json['groupChatId']; setting = json['setting']; } } class ApplyList extends ChangeNotifier { List applyList = []; List applicantIds = []; int count = 0; void init(dynamic json) { for (var element in json) { Apply apply = Apply.fromJson(element); applyList.add(apply); applicantIds.add(element['applicant']); count += 1; } } void removeAt(int index) { applyList.removeAt(index); count--; } void addJson(Map json) { Apply apply = Apply.fromJson(json); applyList.add(apply); count++; } void clean() { applyList = []; applicantIds = []; count = 0; } }