import 'package:flutter/material.dart'; import 'package:flutter_contacts/flutter_contacts.dart'; import 'package:project_telephony/utils/hive_store.dart'; 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: '')); class PhoneNumProvider extends ChangeNotifier{ List? contacts; final List _massList = []; List _phoneList = []; List get massList=>_massList; List 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"); } // Future }