import 'package:hive/hive.dart'; @HiveType(typeId: 0) class PhoneNumberHive{ @HiveField(0) int? id; @HiveField(1) String? title; @HiveField(2) String? time; @HiveField(3) bool? state; @HiveField(4) List? phoneList; PhoneNumberHive({ this.id, this.title, this.time, this.state, this.phoneList, }); PhoneNumberHive.fromJson(Map json){ id=json['id']; title=json['title']; time=json['time']; state=json['state']; if(json['phoneList'] !=null){ phoneList=json['phoneList'].map((e) => PhoneNumModel.from(e)).toList(); }else{ phoneList=[]; } } Map toJson(){ final Map data= {}; data['id'] =id; data['title']=title; data['time']=time; data['state']=state; if(phoneList!=null){ data['phoneList']=phoneList!.map((e) => e.toJson()).toList(); } return data; } } @HiveType(typeId: 1) class PhoneNumModel{ @HiveField(0) int? id; @HiveField(1) String? name; @HiveField(2) String? phone; @HiveField(3) bool? state; PhoneNumModel({ this.id, this.name, this.phone, this.state, }); PhoneNumModel.from(Map json){ id=json['id']; name=json['name']; phone=json['phone']; state=json['state']; } Map toJson(){ final Map data={}; data["id"]=id; data['name']=name; data['phone']=phone; data['state']=state; return data; } }