parent
634a3fcdd1
commit
e8a6602425
@ -0,0 +1,81 @@
|
||||
|
||||
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<PhoneNumModel>? phoneList;
|
||||
|
||||
PhoneNumberHive({
|
||||
this.id,
|
||||
this.title,
|
||||
this.time,
|
||||
this.state,
|
||||
this.phoneList,
|
||||
});
|
||||
PhoneNumberHive.fromJson(Map<String,dynamic> 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<String,dynamic> toJson(){
|
||||
final Map<String,dynamic> data= <String,dynamic>{};
|
||||
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<String,dynamic> json){
|
||||
id=json['id'];
|
||||
name=json['name'];
|
||||
phone=json['phone'];
|
||||
state=json['state'];
|
||||
}
|
||||
Map<String,dynamic> toJson(){
|
||||
final Map<String,dynamic> data=<String,dynamic>{};
|
||||
data["id"]=id;
|
||||
data['name']=name;
|
||||
data['phone']=phone;
|
||||
data['state']=state;
|
||||
return data;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue