You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.5 KiB

2 years ago
import 'package:flutter/material.dart';
import 'package:flutter_contacts/flutter_contacts.dart';
2 years ago
import 'package:project_telephony/utils/hive_store.dart';
2 years ago
import '../model/hive/phone_model.dart';
// await HiveStore.dataBox?.add(PhoneModel(name: full.displayName,phone:full.phones.first.number, state: false));
// phoneList=HiveStore.dataBox?.get(PhoneModel());
// HiveStore.dataBox?.add(PhoneNumberHive(state: false,phoneList: phoneList,title:"未分组联系人",time: ''));
2 years ago
class PhoneNumProvider extends ChangeNotifier{
List<Contact>? contacts;
final List<PhoneModel> _massList = [];
List<PhoneNum> _phoneList = [];
List<PhoneModel> get massList=>_massList;
List<PhoneNum> get phoneList=>_phoneList;
Future init() async{
contacts = await FlutterContacts.getContacts();
for (var element in contacts!) {
final full = await FlutterContacts.getContact(element.id);
_phoneList.add(PhoneNum(name: full?.displayName, phone: full?.phones.first.number,state: false));
//
// print(full?.displayName);
// print(full?.phones.first.number);
}
await HiveStore.dataBox!.put("pl",_phoneList) ;
_massList.add(PhoneModel(title:"未分组联系人",time: "本机通讯录",phoneList:HiveStore.dataBox!.get("pl"),state: false));
HiveStore.dataBox?.put("ml",_massList) ;
// print( "这是我的类型${HiveStore.dataBox?.get("ml").runtimeType}");
}
Future upDate() async{
_phoneList=await HiveStore.dataBox?.get("pl");
2 years ago
}
// Future
}