QuisApp / flutter_contacts

MIT License
88 stars 143 forks source link

Support storing In Hive,ObjectBox. #76

Closed yassinsameh closed 2 years ago

yassinsameh commented 2 years ago

Hi, currently it's not possible to store a Contact object to hive as that object must be immutable and have certain annotations the run a build_runner. Is there a way i'm not aware of that this can be achieved? Besides forking the repo and editing the Contact class? If there is a way that makes sense to support this i would gladly work on it and make a pull request.

yassinsameh commented 2 years ago

Workaround found, storing the contact as Json using the toJson() method and fetching after using the fromJson() method.

akamanocha commented 1 year ago

Hi @yassinsameh can you please help with some sample code .Thanks.

yassinsameh commented 1 year ago

Hi, an example would be to have your class

StoredContact{
required Map<String,dynamic> contact,
}

Then you can store/get your Contact using the toJson() and fromJson() methods.