Question
I am using the hive database for making my items as favorite and show them in a list.
While clicking a button " favoriteBox.add(Favorite(id, name,place,featuredImage,rating,));"
if I click that button again then the same data is coming into the list again.
is there any way to overcome this problem?
I need to know how can I update a column in the hive.
I am just showing the item in a list. I just want to update it from my screen.
if(!favoriteBox.isEmpty){
favoriteBox.put(id, Favorite(id, name,place,featuredImage,rating,));
}else{
favoriteBox.add(Favorite(id, name,place,featuredImage,rating,));
}
Just make sure that the id property from your model is the same as the key returned by box.add and you should be good to go.
When you call box.put it actually takes in the key of your data.
If you're using a model that extends HiveObject, you can use the key getter instead of id in box.put:
final favorite = Favorite(/* [ ... ] */);
await favoriteBox.put(favorite.key, favorite);
Otherwise, if you're using a list, you can get the key for your data through box.keyAt(index).
Dear can give an example for my problem i am not using a list so i dont
have the index there.
I have a details page and an add to favorites button when i click that
button i need to add a some details to list and show it list view when i
add it again its duplicating the data i dont want to duplicate just need to
update if there is same item.
i think you get my point.
On Thu, 31 Dec 2020, 10:17 pm Matheus H. Baumgarten, <
[email protected]> wrote:
Just make sure that the id property from your model is the same as the key
returned by box.add and you should be good to go.When you call box.put it actually takes in the key of your data.
If you're using a model that extends HiveObject, you can use the key
getter instead of id in box.put:final favorite = Favorite(/* [ ... ] */);await favoriteBox.put(favorite.key, favorite);
Otherwise, if you're using a list, you can get the key for your data
through box.keyAt(index).โ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753030568, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFALVF4K7GL4YWXK25LSXTE3DANCNFSM4VPOAP2A
.
Could you please post the code for your Favorite model? And if possible, the code where you add favorites to the box.
It's my Model Class
import 'package:hive/hive.dart';part
'favorite.g.dart';@HiveType(typeId: 1)class Favorite { @HiveField(0)
final int id; @HiveField(1) final String name; @HiveField(2) final
String place; @HiveField(3) final String image; @HiveField(4)
final int reviews; Favorite(this.id, this.name, this.place,
this.image, this.reviews);}
*------Adapter*
part of 'favorite.dart';//
**************************************************************************//
TypeAdapterGenerator//
**************************************************************************class
FavoriteAdapter extends TypeAdapter<Favorite> { @override final
typeId = 1; @override Favorite read(BinaryReader reader) { var
numOfFields = reader.readByte(); var fields = <int, dynamic>{
for (var i = 0; i < numOfFields; i++) reader.readByte():
reader.read(), }; return Favorite( fields[0] as int,
fields[1] as String, fields[2] as String, fields[3] as
String, fields[4] as int, ); } @override void
write(BinaryWriter writer, Favorite obj) { writer
..writeByte(4) ..writeByte(0) ..write(obj.id)
..writeByte(1) ..write(obj.name) ..writeByte(2)
..write(obj.place) ..writeByte(3) ..write(obj.image)
..writeByte(3) ..write(obj.reviews); }}
Here i have a list of my products from list i push to details page of
the products here there is a add to favorite button, when i press that
button it will call this function
favoriteBox.add(Favorite(id, name,place,featuredImage,rating,));
when i click that button again its adding the same item 2 time. here i
need to update that item if its already in that box.
Its is my first time with flutter and hive so please kindly help for
this. hopw you will understand my things
Thank you
On Thu, 31 Dec 2020 at 22:52, Matheus H. Baumgarten <
[email protected]> wrote:
Could you please post the code for your Favorite model?
โ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753054828, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFG7PBNRE6OBCTVXHI3SXTI7FANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Sure! So.
I would suggest you to read through the documentation on hive, it will help a lot.
As your model doesn't extend HiveObject, you will have to find the key of your Favorite class iterating through box.values:
/// Make sure you test if the favorite exists before running this function
Future<void> updateItemById(Box<Favorite> box, int id) async {
final boxEntries = box.values.toList();
// Find your favorite by its id
final favorites = boxEntries.where((fav) => fav.id == id).toList();
if (favorites.isEmpty) return; // favorite not in the box
// Get the index of your favorite in the box
final favIndex = boxEntries.indexOf(favorites.first);
// Update the instance
await box.putAt(favIndex, favorite);
}
An easier way of doing the same thing is using the HiveObject mixin in your model, just add with HiveObject to the definition of Favorite:
// Make sure you run build_runner if you make this change
class Favorite with HiveObject {
// your code
}
Then you will be able to use the methods delete, save and the key getter:
final favorite = Favorite(id: 0);
favoriteBox.add(favorite);
// Update any field thats not final
favorite.id = 1;
await favorite.save(); // updates the favorite without adding a new entry to the box
// If you dont want to mutate the object, you can use `favorite.key`
final oldFavorite = Favorite(id: 0);
final newFavorite = Favorite(id: 1);
await box.put(oldFavorite.key, newFavorite); // use the old key to override the entry with a new Favorite
Then, before adding a new favorite you can check if it exists, and update it accordingly.
Brother here my question is how can i check it is exist or not.
On Fri, 1 Jan 2021 at 14:42, Matheus H. Baumgarten notifications@github.com
wrote:
Sure! So.
I would suggest you to read through the documentation
https://docs.hivedb.dev/#/basics/read_write on hive, it will help a lot.As your model doesn't extend HiveObject, you will have to find the key of
your Favorite class iterating through box.values:/// Make sure you test if the favorite exists before running this function
FutureupdateItemById(Box box, int id) async {
final boxEntries = box.values.toList();// Find your favorite by its id
final favorites = boxEntries.where((fav) => fav.id == id).toList();if (favorites.isEmpty) return; // favorite not in the box
// Get the index of your favorite in the box
final favIndex = boxEntries.indexOf(favorites.first);// Update the instance
await box.putAt(favIndex, favorite);
}An easier way of doing the same thing is using the HiveObject mixin in
your model, just add with HiveObject to the definition of Favorite:// Make sure you run build_runner if you make this changeclass Favorite with HiveObject {
// your code
}Then you will be able to use the methods delete, save and the key getter:
final favorite = Favorite(id: 0);
favoriteBox.add(favorite);
// Update any field thats not finalfavorite.id = 1;
await favorite.save(); // updates the favorite without adding a new entry to the box
// If you dont want to mutate the object, you can usefavorite.keyfinal oldFavorite = Favorite(id: 0);final newFavorite = Favorite(id: 1);
await box.put(oldFavorite.key, newFavorite); // use the old key to override the entry with a new FavoriteThen, before adding a new favorite you can check if it exists, and update
it accordingly.โ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753306525, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFB3D2NRRU4G6FGVVZDSXWYLZANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Oh!
Make sure your model extends HiveObject. Then use the isInBox getter:
Take a look at HiveObject. It helps a lot.
Another way:
final boxList = box.values.toList();
final isInBox = boxList.contains(favorite);
// OR
final favorite = Favorite(id: 0);
final isInBox = box.values.where((fav) => fav.id == favorite.id);
// You can also use .firstWhere()
Hope this time I understood you. Let me know if it worked ๐
Thank you so much
On Sat, 2 Jan 2021 at 11:59 AM, Matheus H. Baumgarten <
[email protected]> wrote:
Oh!
Make sure your model extends HiveObject. Then use the isInBoxgetter:
Take a look at HiveObject
https://www.github.com/hivedb/hive/tree/master/hive%2Flib%2Fsrc%2Fobject%2Fhive_object.dart
.Another way:
final boxList = box.values.toList();
final isInBox = boxList.contains(favorite);// OR
final favorite = Favorite(id: 0);
final isInBox = box.values.where((fav) => fav.id == favorite.id);
// You can also use .firstWhere()Hope this time I undertood you. Let me know if it worked ๐
โ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753449490, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFFT4MDDI2C7IOEU2NDSX3N6RANCNFSM4VPOAP2A
.>
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
@TheMisir we can close this one ๐
Yes sure
On Sat, 2 Jan 2021, 12:36 pm Matheus H. Baumgarten, <
[email protected]> wrote:
@TheMisir https://github.com/TheMisir we can close this one ๐
โ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753452431, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFEAXVECVLZKCNBC7ELSX3SKZANCNFSM4VPOAP2A
.
Hi bro
Thank you for helping me.
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception:
HiveError: Cannot write, unknown type: CompletedHistoryRecord. Did you
forget to register an adapter?
Hive.init((await getApplicationDocumentsDirectory()).path);
Hive.registerAdapter
Hive.registerAdapter
await Future.wait([Hive.openBox
await Future.wait([Hive.openBox
historyBox.add(History(_upComingHistoryRecord,_completedHistoryRecord));
Model
import 'package:mytableqatar/data/model/completed_history_model.dart';
import 'package:mytableqatar/data/model/upcoming_history_model.dart';
import 'package:hive/hive.dart';
part 'history.g.dart';
@HiveType(typeId: 2)
class History extends HiveObject{
@HiveField(0)
List
@HiveField(1)
List
History(this._upComingHistoryRecord, this._completedHistoryRecord);
}
Adapter
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'history.dart';
//
// TypeAdapterGenerator
//
class HistoryAdapter extends TypeAdapter
@override
final int typeId = 2;
@override
History read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields =
for (int i = 0; i < numOfFields; i++) reader.readByte():
reader.read(),
};
return History(
(fields[0] as List)?.cast
(fields[1] as List)?.cast
);
}
@override
void write(BinaryWriter writer, History obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj._upComingHistoryRecord)
..writeByte(1)
..write(obj._completedHistoryRecord);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HistoryAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
CAN YOU TELL WHAT IS THE PROBLEM HERE.
On Sat, 2 Jan 2021 at 12:39, Misir Jafarov notifications@github.com wrote:
Closed #530 https://github.com/hivedb/hive/issues/530.
โ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#event-4161590161, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFFXF3ZYY5ATG4U3HO3SX3SV7ANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Hey @muhammednazil , You have to generate and register adapter for CompletedHistoryRecord class.
Can you please explain this to me?
On Sun, 3 Jan 2021 at 13:25, Misir Jafarov notifications@github.com wrote:
Hey @muhammednazil https://github.com/muhammednazil , You have to
generate and register adapter for CompletedHistoryRecord class.โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753596066, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFGOQ5GE5P2LKAXBHH3SYBAZJANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Could you please share the code for UpComingHistoryRecord and CompletedHistoryRecord?
import 'package:mytableqatar/data/model/completed_history_model.dart';
import 'package:mytableqatar/data/model/upcoming_history_model.dart';
import 'package:hive/hive.dart';
part 'history.g.dart';
@HiveType(typeId: 2)
class History extends HiveObject{
@HiveField(0)
List
@HiveField(1)
List
History(this._upComingHistoryRecord, this._completedHistoryRecord);
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'history.dart';
// ***********************
// TypeAdapterGenerator
// ***********************
class HistoryAdapter extends TypeAdapter
@override
final int typeId = 2;
@override
History read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields =
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return History(
(fields[0] as List)?.cast
(fields[1] as List)?.cast
);
}
@override
void write(BinaryWriter writer, History obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj._upComingHistoryRecord)
..writeByte(1)
..write(obj._completedHistoryRecord);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HistoryAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
On Sun, 3 Jan 2021 at 14:21, Matheus H. Baumgarten notifications@github.com
wrote:
Could you please share the code for UpComingHistoryRecord?
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753602176, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFBTX7JF6DIMVKM3EHLSYBHM7ANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
class CompletedHistoryRecord {
CompletedHistoryRecord({
this.companyId,
this.partnerId,
this.state,
this.datetimeEnd,
this.datetimeStart,
this.name,
this.id,
this.extraProductIds,
this.resourceId,
this.no_of_adults,
this.no_of_child
});
List
List
String state;
String datetimeEnd;
String datetimeStart;
String name;
int id;
List
List
String no_of_adults;
String no_of_child;
factory CompletedHistoryRecord.fromJson(Map
=> CompletedHistoryRecord(
companyId: List
partnerId: List
state: json["state"],
datetimeEnd: json["datetime_end"],
datetimeStart: json["datetime_start"],
name: json["name"],
id: json["id"],
extraProductIds:
List
resourceId: List
no_of_adults: json["no_of_adults"],
no_of_child: json["no_of_child"],
);
Map
"company_id": List
"partner_id": List
"state": state,
"datetime_end": datetimeEnd,
"datetime_start": datetimeStart,
"name": name,
"id": id,
"extra_product_ids": List
"resource_id": List
"no_of_adults": no_of_adults,
"no_of_adults": no_of_adults,
};
}
class UpComingHistoryRecord {
UpComingHistoryRecord({
this.companyId,
this.partnerId,
this.state,
this.datetimeEnd,
this.datetimeStart,
this.name,
this.id,
this.extraProductIds,
this.resourceId,
this.no_of_adults,
this.no_of_child
});
List
List
String state;
String datetimeEnd;
String datetimeStart;
String name;
int id;
List
List
String no_of_adults;
String no_of_child;
factory UpComingHistoryRecord.fromJson(Map
UpComingHistoryRecord(
companyId: List
partnerId: List
state: json["state"],
datetimeEnd: json["datetime_end"],
datetimeStart: json["datetime_start"] ,
name: json["name"],
id: json["id"],
extraProductIds:
List
resourceId: List
no_of_adults: json["no_of_adults"],
no_of_child: json["no_of_child"],
);
Map
"company_id": List
"partner_id": List
"state": state,
"datetime_end": datetimeEnd,
"datetime_start": datetimeStart,
"name": name,
"id": id,
"extra_product_ids": List
"resource_id": List
"no_of_adults": no_of_adults,
"no_of_adults": no_of_adults,
};
}
On Sun, 3 Jan 2021 at 14:45, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:
import 'package:mytableqatar/data/model/completed_history_model.dart';
import 'package:mytableqatar/data/model/upcoming_history_model.dart';
import 'package:hive/hive.dart';
part 'history.g.dart';@HiveType(typeId: 2)
class History extends HiveObject{
@HiveField(0)
List_upComingHistoryRecord = [];
@HiveField(1)
List_completedHistoryRecord = []; History(this._upComingHistoryRecord, this._completedHistoryRecord);
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'history.dart';
// ***********************
// TypeAdapterGenerator
// ***********************class HistoryAdapter extends TypeAdapter
{
@override
final int typeId = 2;@override
History read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields ={
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return History(
(fields[0] as List)?.cast(),
(fields[1] as List)?.cast(),
);
}@override
void write(BinaryWriter writer, History obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj._upComingHistoryRecord)
..writeByte(1)
..write(obj._completedHistoryRecord);
}@override
int get hashCode => typeId.hashCode;@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HistoryAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}On Sun, 3 Jan 2021 at 14:21, Matheus H. Baumgarten <
[email protected]> wrote:Could you please share the code for UpComingHistoryRecord?
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753602176, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFBTX7JF6DIMVKM3EHLSYBHM7ANCNFSM4VPOAP2A
.--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
You cannot have a class inside a @HiveType that doesn't have an adabter. (Hive only supports primitive types, like String, int, Map, List, ..., all other types must be registered)
For your approach to work you would either have to make CompletedHistoryRecord into a @HiveType and use a Hive List to save it inside History or use methods like toMap() and fromMap() to save a Dart Map of your data models inside History.
For simplicity you can add @HiveType annotation to your model to fix the issue.
@HiveType(typeId: 3)
class UpComingHistoryRecord {
...
Can you please provide me with an example for this.
I am first time
On Sun, 3 Jan 2021 at 15:48, Matheus H. Baumgarten notifications@github.com
wrote:
You cannot have a class inside a @HiveType that doesn't have an adabter.
(Hive only supports primitive types, like String, int, Map, List, ..., all
other types must be registered)For your approach to work you would either have to make
CompletedHistoryRecord into a @HiveType and use a Hive List
https://docs.hivedb.dev/#/custom-objects/relationships?id=hivelists to
save it inside History or use methods like toMap() and fromMap() to
save a Dart Map of your data models inside History.โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753612167, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFCFYMIBJSOFYRWVWT3SYBRRPANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Do the same things you did to Favorite and History with your other models, like @TheMisir showed above.
so i can't use that model in the hive
On Sun, 3 Jan 2021 at 16:59, Matheus H. Baumgarten notifications@github.com
wrote:
Do the same things you dit to Favorite and History with your other
models, like Misir showed above.โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753621415, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFEMFXZOL5ONNZWAQYDSYBZ3TANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Yes you can! But you have to register an adapter for it:
@HiveType(typeId: 5 /*any int < 255 here. Look out for duplicates*/);
class CompletedHistoryRecord {
CompletedHistoryRecord({this.id, this.name});
// Mark the properties you want to store with @HiveField(). For example:
@HiveField(0)
final int id;
@HiveField(1)
final String name;
// [ ... ] Other properties and methods
}
And do the same for the UpComing model.
Then run build_runner again and register the adapters.
Another way is changing the History model to store maps instead of your models:
@HiveField(0)
final List<Map<String, dynamic>> _upComingHistoryRecord;
// And
@HiveField(1)
final List<Map<String, dynamic>> _completedHistoryRecord;
Then when you instantiate History do it like so:
final history = History(
[completedHistoryRecordInstance.toJson()],
[upComingHistoryRecordInstance.toJson()],
);
// Use the instances, or a list with the instances:
final history = History(
listOfCompletedHistoryRecord.map((value) => value.toJson()).toList(),
listOfUpComingHistoryRecord.map((value) => value.toJson()).toList(),
);
Then in History, add getters for converting back:
List<CompletedHistoryRecord> get completedHistoryRecord {
return _completedHistoryRecord.map((value) => CompletedHistoryRecord.fromJson(value)).toList();
}
// Do the same for UpComing
I will try thank you
On Sun, 3 Jan 2021 at 17:41, Matheus H. Baumgarten notifications@github.com
wrote:
Another way is changing the History model to store maps instead of your
models:@HiveField(0)final List
Then when you instantiate History do it like so:
final history = History(
[completedHistoryRecordInstance.toJson()],
[upComingHistoryRecordInstance.toJson()],
);// Use the instances, or a list with the instances:final history = History(
listOfCompletedHistoryRecord.map((value) => value.toJson()).toList(),
listOfUpComingHistoryRecord.map((value) => value.toJson()).toList(),
);Then in History, add getters for converting back:
List
get completedHistoryRecord {
return _completedHistoryRecord.map((value) => CompletedHistoryRecord.fromJson(value)).toList();
}
// Do the same for UpComingโ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753627396, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFDSXMX77U6I3RBDGRDSYB6X5ANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception:
MissingPluginException(No implementation found for method
getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider
)
Why this is showing
Hive.init((await getApplicationDocumentsDirectory()).path);
Hive.registerAdapter
Hive.registerAdapter
await Future.wait([Hive.openBox
await Future.wait([Hive.openBox
On Mon, 4 Jan 2021 at 08:37, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:
I will try thank you
On Sun, 3 Jan 2021 at 17:41, Matheus H. Baumgarten <
[email protected]> wrote:Another way is changing the History model to store maps instead of your
models:@HiveField(0)final List
> _upComingHistoryRecord;
// And
@HiveField(1)final List> _completedHistoryRecord; Then when you instantiate History do it like so:
final history = History(
[completedHistoryRecordInstance.toJson()],
[upComingHistoryRecordInstance.toJson()],
);// Use the instances, or a list with the instances:final history = History(
listOfCompletedHistoryRecord.map((value) => value.toJson()).toList(),
listOfUpComingHistoryRecord.map((value) => value.toJson()).toList(),
);Then in History, add getters for converting back:
List
get completedHistoryRecord {
return _completedHistoryRecord.map((value) => CompletedHistoryRecord.fromJson(value)).toList();
}
// Do the same for UpComingโ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753627396, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFDSXMX77U6I3RBDGRDSYB6X5ANCNFSM4VPOAP2A
.--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Seems like an error with the package path_provider. I would recommend that you use Hive.initFlutter() from the hive_flutter package as it resolves the paths for you ๐
import 'package:hive_flutter/hive_flutter.dart';
void main() async {
await Hive.initFlutter();
// [ ... ]
}
https://medium.com/@themitshah/hive-initflutter-not-working-no-such-method-in-hive-65047c15a67a
On Mon, 4 Jan 2021 at 14:08, Matheus H. Baumgarten notifications@github.com
wrote:
Seems like an error with the package path_provider. I would recommend
that you use Hive.initFlutter() from the hive_flutter package as it
resolves the paths for you ๐โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753912879, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFECOMIPWLI2IB3F5VDSYGOULANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
: Fatal: failed to find callback
E/flutter ( 6942): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled
Exception: MissingPluginException(No implementation found for method
getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider
)
E/flutter ( 6942): #0 MethodChannel._invokeMethod
(package:flutter/src/services/platform_channel.dart:157:7)
E/flutter ( 6942):
E/flutter ( 6942): #1 MethodChannel.invokeMethod
(package:flutter/src/services/platform_channel.dart:332:12)
E/flutter ( 6942): #2
MethodChannelPathProvider.getApplicationDocumentsPath
(package:path_provider_platform_interface/src/method_channel_path_provider.dart:50:10)
E/flutter ( 6942): #3 getApplicationDocumentsDirectory
(package:path_provider/path_provider.dart:76:39)
E/flutter ( 6942): #4 HiveX.initFlutter
(package:hive_flutter/src/hive_extensions.dart:11:26)
E/flutter ( 6942): #5 main (package:mytableqatar/main.dart:57:16)
E/flutter ( 6942): #6 _runMainZoned.
E/flutter ( 6942): #7 _rootRun (dart:async/zone.dart:1190:13)
E/flutter ( 6942): #8 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter ( 6942): #9 _runZoned (dart:async/zone.dart:1630:10)
E/flutter ( 6942): #10 runZonedGuarded (dart:async/zone.dart:1618:12)
E/flutter ( 6942): #11 _runMainZoned.
(dart:ui/hooks.dart:223:5)
E/flutter ( 6942): #12 _startIsolate.
(dart:isolate-patch/isolate_patch.dart:301:19)
E/flutter ( 6942): #13 _RawReceivePortImpl._handleMessage
(dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter ( 6942):
W/ConnectionTracker( 6942): Exception thrown while unbinding
W/ConnectionTracker( 6942): java.lang.IllegalArgumentException: Service not
registered: ls@5c78b46
W/ConnectionTracker( 6942): at
android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1870)
W/ConnectionTracker( 6942): at
android.app.ContextImpl.unbindService(ContextImpl.java:1848)
W/ConnectionTracker( 6942): at
android.content.ContextWrapper.unbindService(ContextWrapper.java:755)
W/ConnectionTracker( 6942): at
ci.f(:com.google.android.gms.dynamite_measurementdynamite@[email protected]
(120400-0):1)
W/ConnectionTracker( 6942): at
ci.d(:com.google.android.gms.dynamite_measurementdynamite@[email protected]
(120400-0):2)
W/ConnectionTracker( 6942): at
lt.E(:com.google.android.gms.dynamite_measurementdynamite@[email protected]
(120400-0):9)
W/ConnectionTracker( 6942): at
ld.a(:com.google.android.gms.dynamite_measurementdynamite@[email protected]
(120400-0):3)
W/ConnectionTracker( 6942): at
ef.run(:com.google.android.gms.dynamite_measurementdynamite@[email protected]
(120400-0):3)
W/ConnectionTracker( 6942): at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
W/ConnectionTracker( 6942): at
java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/ConnectionTracker( 6942): at
iy.run(:com.google.android.gms.dynamite_measurementdynamite@[email protected]
(120400-0):5)
The same error is happening
HttpOverrides.global = new MyHttpOverrides();
WidgetsFlutterBinding.ensureInitialized();
await Hive.initFlutter();
Hive.registerAdapter
Hive.registerAdapter
await Future.wait([Hive.openBox
await Future.wait([Hive.openBox
On Mon, 4 Jan 2021 at 14:16, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:
>
https://medium.com/@themitshah/hive-initflutter-not-working-no-such-method-in-hive-65047c15a67a
On Mon, 4 Jan 2021 at 14:08, Matheus H. Baumgarten <
[email protected]> wrote:Seems like an error with the package path_provider. I would recommend
that you use Hive.initFlutter() from the hive_flutter package as it
resolves the paths for you ๐โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753912879, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFECOMIPWLI2IB3F5VDSYGOULANCNFSM4VPOAP2A
.--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Hive.initFlutter already calls WidgetsFlutterBinding.ensureInitialized(), so you don't have to.
Oh, and make sure you add hive_flutter: ^0.3.1 as a dependency.
Try the following:
flutter cleanflutter pub cache repairflutter pub getLet me know if this works!
The same happens
Launching lib/main.dart on SM G973F in debug mode...
Running Gradle task 'assembleDebug'...
โ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
Waiting for SM G973F to report its views...
Debug service listening on ws://127.0.0.1:51665/JQeNiEQaxpQ=/ws
Syncing files to device SM G973F...
E/FlutterFcmService(30716): Fatal: failed to find callback
E/flutter (30716): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled
Exception: HiveError: You need to initialize Hive or provide a path to
store the box.
E/flutter (30716): #0 BackendManager.open
(package:hive/src/backend/vm/backend_manager.dart:16:7)
E/flutter (30716): #1 HiveImpl._openBox
(package:hive/src/hive_impl.dart:96:30)
E/flutter (30716): #2 HiveImpl.openBox
(package:hive/src/hive_impl.dart:135:18)
E/flutter (30716): #3 main (package:mytableqatar/main.dart:60:27)
E/flutter (30716): #4 _runMainZoned.
E/flutter (30716): #5 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (30716): #6 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (30716): #7 _runZoned (dart:async/zone.dart:1630:10)
E/flutter (30716): #8 runZonedGuarded (dart:async/zone.dart:1618:12)
E/flutter (30716): #9 _runMainZoned.
(dart:ui/hooks.dart:223:5)
E/flutter (30716): #10 _startIsolate.
(dart:isolate-patch/isolate_patch.dart:301:19)
E/flutter (30716): #11 _RawReceivePortImpl._handleMessage
(dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter (30716):
E/flutter (30716): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled
Exception: HiveError: You need to initialize Hive or provide a path to
store the box.
E/flutter (30716): #0 BackendManager.open
(package:hive/src/backend/vm/backend_manager.dart:16:7)
E/flutter (30716): #1 HiveImpl._openBox
(package:hive/src/hive_impl.dart:96:30)
E/flutter (30716): #2 HiveImpl.openBox
(package:hive/src/hive_impl.dart:135:18)
E/flutter (30716): #3 main (package:mytableqatar/main.dart:60:27)
E/flutter (30716): #4 _runMainZoned.
E/flutter (30716): #5 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (30716): #6 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (30716): #7 _runZoned (dart:async/zone.dart:1630:10)
E/flutter (30716): #8 runZonedGuarded (dart:async/zone.dart:1618:12)
E/flutter (30716): #9 _runMainZoned.
(dart:ui/hooks.dart:223:5)
E/flutter (30716): #10 _startIsolate.
(dart:isolate-patch/isolate_patch.dart:301:19)
E/flutter (30716): #11 _RawReceivePortImpl._handleMessage
(dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter (30716):
E/flutter (30716): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled
Exception: MissingPluginException(No implementation found for method
getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider
)
E/flutter (30716): #0 MethodChannel._invokeMethod
(package:flutter/src/services/platform_channel.dart:157:7)
E/flutter (30716):
E/flutter (30716): #1 MethodChannel.invokeMethod
(package:flutter/src/services/platform_channel.dart:332:12)
E/flutter (30716): #2
MethodChannelPathProvider.getApplicationDocumentsPath
(package:path_provider_platform_interface/src/method_channel_path_provider.dart:50:10)
E/flutter (30716): #3 getApplicationDocumentsDirectory
(package:path_provider/path_provider.dart:104:39)
E/flutter (30716): #4 HiveX.initFlutter
(package:hive_flutter/src/hive_extensions.dart:11:26)
E/flutter (30716): #5 main (package:mytableqatar/main.dart:54:10)
E/flutter (30716): #6 _runMainZoned.
E/flutter (30716): #7 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (30716): #8 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (30716): #9 _runZoned (dart:async/zone.dart:1630:10)
E/flutter (30716): #10 runZonedGuarded (dart:async/zone.dart:1618:12)
E/flutter (30716): #11 _runMainZoned.
(dart:ui/hooks.dart:223:5)
E/flutter (30716): #12 _startIsolate.
(dart:isolate-patch/isolate_patch.dart:301:19)
E/flutter (30716): #13 _RawReceivePortImpl._handleMessage
(dart:isolate-patch/isolate_patch.dart:168:12)
On Mon, 4 Jan 2021 at 15:27, Matheus H. Baumgarten notifications@github.com
wrote:
Hive.initFlutter already calls WidgetsFlutterBinding.ensureInitialized(),
so you don't have to.Try the following:
- Stop your app
- Run flutter clean
- Run flutter pub cache repair
- Run flutter pub get
- Start your app again
Let me know if this works!
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753947531, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFEZAU3BHDGSL52KOALSYGX4HANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Did you await the initFlutter?
Can I see the contents of your pubspec.yaml?
I ran out of ideas, perhaps @TheMisir knows whats going on.
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception:
NoSuchMethodError: The getter 'upComingHistoryRecord' was called on null.
E/flutter (25883): Receiver: null
E/flutter (25883): Tried calling: upComingHistoryRecord
E/flutter (25883): #0 Object.noSuchMethod
(dart:core-patch/object_patch.dart:51:5)
E/flutter (25883): #1 _SplashScreenState.initState.
(package:mytableqatar/ui/SplashScreen.dart:141:77)
E/flutter (25883): #2 _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (25883): #3 _CustomZone.runUnary
(dart:async/zone.dart:1100:19)
E/flutter (25883): #4 _FutureListener.handleValue
(dart:async/future_impl.dart:143:18)
E/flutter (25883): #5 Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:696:45)
E/flutter (25883): #6 Future._propagateToListeners
(dart:async/future_impl.dart:725:32)
E/flutter (25883): #7 Future._completeWithValue
(dart:async/future_impl.dart:529:5)
E/flutter (25883): #8 _AsyncAwaitCompleter.complete
(dart:async-patch/async_patch.dart:40:15)
E/flutter (25883): #9 _completeOnAsyncReturn
(dart:async-patch/async_patch.dart:311:13)
E/flutter (25883): #10 Base.isConnected (package:mytableqatar/base.dart)
E/flutter (25883): #11 _asyncErrorWrapperHelper.errorCallback
(dart:async-patch/async_patch.dart:91:64)
E/flutter (25883): #12 _rootRunBinary (dart:async/zone.dart:1214:47)
E/flutter (25883): #13 _CustomZone.runBinary
(dart:async/zone.dart:1107:19)
E/flutter (25883): #14 _FutureListener.handleError
(dart:async/future_impl.dart:157:20)
E/flutter (25883): #15 Future._propagateToListeners.handleError
(dart:async/future_impl.dart:708:47)
E/flutter (25883): #16 Future._propagateToListeners
(dart:async/future_impl.dart:729:24)
E/flutter (25883): #17 Future._completeWithValue
(dart:async/future_impl.dart:529:5)
E/flutter (25883): #18 Future._asyncCompleteWithValue.
E/flutter (25883): #19 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (25883): #20 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (25883): #21 _CustomZone.runGuarded
(dart:async/zone.dart:997:7)
E/flutter (25883): #22 _CustomZone.bindCallbackGuarded.
E/flutter (25883): #23 _microtaskLoop
(dart:async/schedule_microtask.dart:41:21)
E/flutter (25883): #24 _startMicrotaskLoop
(dart:async/schedule_microtask.dart:50:5)
E/flutter (25883):
How can i retrieve this list in another class
On Sun, 3 Jan 2021 at 17:41, Matheus H. Baumgarten notifications@github.com
wrote:
Another way is changing the History model to store maps instead of your
models:@HiveField(0)final List
> _upComingHistoryRecord;
// And
@HiveField(1)final List> _completedHistoryRecord; Then when you instantiate History do it like so:
final history = History(
[completedHistoryRecordInstance.toJson()],
[upComingHistoryRecordInstance.toJson()],
);// Use the instances, or a list with the instances:final history = History(
listOfCompletedHistoryRecord.map((value) => value.toJson()).toList(),
listOfUpComingHistoryRecord.map((value) => value.toJson()).toList(),
);Then in History, add getters for converting back:
List
get completedHistoryRecord {
return _completedHistoryRecord.map((value) => CompletedHistoryRecord.fromJson(value)).toList();
}
// Do the same for UpComingโ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753627396, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFDSXMX77U6I3RBDGRDSYB6X5ANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
import 'package:mytableqatar/data/model/completed_history_model.dart';
import 'package:mytableqatar/data/model/upcoming_history_model.dart';
import 'package:hive/hive.dart';
part 'history.g.dart';
@HiveType(typeId: 2)
class History extends HiveObject{
@HiveField(0)
final List
@HiveField(1)
final List
History(this._upComingHistoryRecord, this._completedHistoryRecord);
List
return _upComingHistoryRecord.map((value) =>
UpComingHistoryRecord.fromJson(value)).toList();
}
List
return _completedHistoryRecord.map((value) =>
CompletedHistoryRecord.fromJson(value)).toList();
}
}
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'history.dart';
// ***********************
// TypeAdapterGenerator
// ***********************
class HistoryAdapter extends TypeAdapter
@override
final int typeId = 2;
@override
History read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields =
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return History(
(fields[0] as List)?.cast
(fields[1] as List)?.cast
);
}
@override
void write(BinaryWriter writer, History obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj._upComingHistoryRecord)
..writeByte(1)
..write(obj._completedHistoryRecord);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HistoryAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}.
How can i call the getter
On Mon, 4 Jan 2021 at 16:53, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception:
NoSuchMethodError: The getter 'upComingHistoryRecord' was called on null.
E/flutter (25883): Receiver: null
E/flutter (25883): Tried calling: upComingHistoryRecord
E/flutter (25883): #0 Object.noSuchMethod
(dart:core-patch/object_patch.dart:51:5)
E/flutter (25883): #1 _SplashScreenState.initState.closure>.
(package:mytableqatar/ui/SplashScreen.dart:141:77)
E/flutter (25883): #2 _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (25883): #3 _CustomZone.runUnary
(dart:async/zone.dart:1100:19)
E/flutter (25883): #4 _FutureListener.handleValue
(dart:async/future_impl.dart:143:18)
E/flutter (25883): #5
Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:696:45)
E/flutter (25883): #6 Future._propagateToListeners
(dart:async/future_impl.dart:725:32)
E/flutter (25883): #7 Future._completeWithValue
(dart:async/future_impl.dart:529:5)
E/flutter (25883): #8 _AsyncAwaitCompleter.complete
(dart:async-patch/async_patch.dart:40:15)
E/flutter (25883): #9 _completeOnAsyncReturn
(dart:async-patch/async_patch.dart:311:13)
E/flutter (25883): #10 Base.isConnected
(package:mytableqatar/base.dart)
E/flutter (25883): #11 _asyncErrorWrapperHelper.errorCallback
(dart:async-patch/async_patch.dart:91:64)
E/flutter (25883): #12 _rootRunBinary (dart:async/zone.dart:1214:47)
E/flutter (25883): #13 _CustomZone.runBinary
(dart:async/zone.dart:1107:19)
E/flutter (25883): #14 _FutureListener.handleError
(dart:async/future_impl.dart:157:20)
E/flutter (25883): #15 Future._propagateToListeners.handleError
(dart:async/future_impl.dart:708:47)
E/flutter (25883): #16 Future._propagateToListeners
(dart:async/future_impl.dart:729:24)
E/flutter (25883): #17 Future._completeWithValue
(dart:async/future_impl.dart:529:5)
E/flutter (25883): #18 Future._asyncCompleteWithValue.closure> (dart:async/future_impl.dart:567:7)
E/flutter (25883): #19 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (25883): #20 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (25883): #21 _CustomZone.runGuarded
(dart:async/zone.dart:997:7)
E/flutter (25883): #22 _CustomZone.bindCallbackGuarded.closure> (dart:async/zone.dart:1037:23)
E/flutter (25883): #23 _microtaskLoop
(dart:async/schedule_microtask.dart:41:21)
E/flutter (25883): #24 _startMicrotaskLoop
(dart:async/schedule_microtask.dart:50:5)
E/flutter (25883):How can i retrieve this list in another class
On Sun, 3 Jan 2021 at 17:41, Matheus H. Baumgarten <
[email protected]> wrote:Another way is changing the History model to store maps instead of your
models:@HiveField(0)final List
> _upComingHistoryRecord;
// And
@HiveField(1)final List> _completedHistoryRecord; Then when you instantiate History do it like so:
final history = History(
[completedHistoryRecordInstance.toJson()],
[upComingHistoryRecordInstance.toJson()],
);// Use the instances, or a list with the instances:final history = History(
listOfCompletedHistoryRecord.map((value) => value.toJson()).toList(),
listOfUpComingHistoryRecord.map((value) => value.toJson()).toList(),
);Then in History, add getters for converting back:
List
get completedHistoryRecord {
return _completedHistoryRecord.map((value) => CompletedHistoryRecord.fromJson(value)).toList();
}
// Do the same for UpComingโ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753627396, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFDSXMX77U6I3RBDGRDSYB6X5ANCNFSM4VPOAP2A
.--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Can you please reply for this.
On Mon, 4 Jan 2021 at 17:04, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:
import 'package:mytableqatar/data/model/completed_history_model.dart';
import 'package:mytableqatar/data/model/upcoming_history_model.dart';
import 'package:hive/hive.dart';
part 'history.g.dart';@HiveType(typeId: 2)
class History extends HiveObject{
@HiveField(0)
final List> _upComingHistoryRecord;
@HiveField(1)
final List> _completedHistoryRecord; History(this._upComingHistoryRecord, this._completedHistoryRecord);
List
get upComingHistoryRecord {
return _upComingHistoryRecord.map((value) => UpComingHistoryRecord.fromJson(value)).toList();
}List
get completedHistoryRecord {
return _completedHistoryRecord.map((value) => CompletedHistoryRecord.fromJson(value)).toList();
}
}// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'history.dart';
// ***********************
// TypeAdapterGenerator
// ***********************class HistoryAdapter extends TypeAdapter
{
@override
final int typeId = 2;@override
History read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields ={
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return History(
(fields[0] as List)?.cast>(),
(fields[1] as List)?.cast>(),
);
}@override
void write(BinaryWriter writer, History obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj._upComingHistoryRecord)
..writeByte(1)
..write(obj._completedHistoryRecord);
}@override
int get hashCode => typeId.hashCode;@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HistoryAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}.
How can i call the getter
On Mon, 4 Jan 2021 at 16:53, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception:
NoSuchMethodError: The getter 'upComingHistoryRecord' was called on null.
E/flutter (25883): Receiver: null
E/flutter (25883): Tried calling: upComingHistoryRecord
E/flutter (25883): #0 Object.noSuchMethod
(dart:core-patch/object_patch.dart:51:5)
E/flutter (25883): #1 _SplashScreenState.initState.closure>.
(package:mytableqatar/ui/SplashScreen.dart:141:77)
E/flutter (25883): #2 _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (25883): #3 _CustomZone.runUnary
(dart:async/zone.dart:1100:19)
E/flutter (25883): #4 _FutureListener.handleValue
(dart:async/future_impl.dart:143:18)
E/flutter (25883): #5
Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:696:45)
E/flutter (25883): #6 Future._propagateToListeners
(dart:async/future_impl.dart:725:32)
E/flutter (25883): #7 Future._completeWithValue
(dart:async/future_impl.dart:529:5)
E/flutter (25883): #8 _AsyncAwaitCompleter.complete
(dart:async-patch/async_patch.dart:40:15)
E/flutter (25883): #9 _completeOnAsyncReturn
(dart:async-patch/async_patch.dart:311:13)
E/flutter (25883): #10 Base.isConnected
(package:mytableqatar/base.dart)
E/flutter (25883): #11 _asyncErrorWrapperHelper.errorCallback
(dart:async-patch/async_patch.dart:91:64)
E/flutter (25883): #12 _rootRunBinary (dart:async/zone.dart:1214:47)
E/flutter (25883): #13 _CustomZone.runBinary
(dart:async/zone.dart:1107:19)
E/flutter (25883): #14 _FutureListener.handleError
(dart:async/future_impl.dart:157:20)
E/flutter (25883): #15 Future._propagateToListeners.handleError
(dart:async/future_impl.dart:708:47)
E/flutter (25883): #16 Future._propagateToListeners
(dart:async/future_impl.dart:729:24)
E/flutter (25883): #17 Future._completeWithValue
(dart:async/future_impl.dart:529:5)
E/flutter (25883): #18 Future._asyncCompleteWithValue.closure> (dart:async/future_impl.dart:567:7)
E/flutter (25883): #19 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (25883): #20 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (25883): #21 _CustomZone.runGuarded
(dart:async/zone.dart:997:7)
E/flutter (25883): #22 _CustomZone.bindCallbackGuarded.closure> (dart:async/zone.dart:1037:23)
E/flutter (25883): #23 _microtaskLoop
(dart:async/schedule_microtask.dart:41:21)
E/flutter (25883): #24 _startMicrotaskLoop
(dart:async/schedule_microtask.dart:50:5)
E/flutter (25883):How can i retrieve this list in another class
On Sun, 3 Jan 2021 at 17:41, Matheus H. Baumgarten <
[email protected]> wrote:Another way is changing the History model to store maps instead of your
models:@HiveField(0)final List
> _upComingHistoryRecord;
// And
@HiveField(1)final List> _completedHistoryRecord; Then when you instantiate History do it like so:
final history = History(
[completedHistoryRecordInstance.toJson()],
[upComingHistoryRecordInstance.toJson()],
);// Use the instances, or a list with the instances:final history = History(
listOfCompletedHistoryRecord.map((value) => value.toJson()).toList(),
listOfUpComingHistoryRecord.map((value) => value.toJson()).toList(),
);Then in History, add getters for converting back:
List
get completedHistoryRecord {
return _completedHistoryRecord.map((value) => CompletedHistoryRecord.fromJson(value)).toList();
}
// Do the same for UpComingโ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-753627396, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFDSXMX77U6I3RBDGRDSYB6X5ANCNFSM4VPOAP2A
.--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Actually the error tells "NoSuchMethodError: The getter 'upComingHistoryRecord' was called on null." which means History object that you're trying to retrieve upComingHistoryRecord property from is null. I'm not sure but it might worth checking if history object is null or not before getting properties.
import 'package:mytableqatar/data/model/completed_history_model.dart';
import 'package:mytableqatar/data/model/upcoming_history_model.dart';
import 'package:hive/hive.dart';
part 'history.g.dart';
@HiveType(typeId: 2)
class History extends HiveObject{
@HiveField(0)
final List
@HiveField(1)
final List
History(
this._upComingHistoryRecord,
this._completedHistoryRecord,
) : assert(_upComingHistoryRecord != null,
'_upComingHistoryRecord cannot be null.'),
assert(_completedHistoryRecord != null,
'_completedHistoryRecord cannot be null.');
List
return _upComingHistoryRecord.map((value) =>
UpComingHistoryRecord.fromJson(value)).toList();
}
List
return _completedHistoryRecord.map((value) =>
CompletedHistoryRecord.fromJson(value)).toList();
}
}
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'history.dart';
// ***********************
// TypeAdapterGenerator
// ***********************
class HistoryAdapter extends TypeAdapter
@override
final int typeId = 2;
@override
History read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields =
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return History(
(fields[0] as List)?.cast
(fields[1] as List)?.cast
);
}
@override
void write(BinaryWriter writer, History obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj._upComingHistoryRecord)
..writeByte(1)
..write(obj._completedHistoryRecord);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HistoryAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
final boxList = historyBox.values.toList();
print(boxList);
History history;
final a = history.completedHistoryRecord;
the items are there in boxList
but this is an error
On Mon, 4 Jan 2021 at 23:26, Misir Jafarov notifications@github.com wrote:
Actually the error tells "NoSuchMethodError: The getter
'upComingHistoryRecord' was called on null." which means History object
that you're trying to retrieve upComingHistoryRecord property from is
null. I'm not sure but it might worth checking if history object is null or
not before getting properties.โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-754199116, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFDYS42EXFJNC4772JLSYIQADANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
History history; does not instantiate nor have any reference to an object, you just created a null variable, try like so:
final historyList = historyBox.values.toList();
final history = historyList.first; // same as calling list[0]
final a = history.completedHistoryRecord;
[ERROR:flutter/shell/common/shell.cc(210)] Dart Unhandled Exception: type
'_InternalLinkedHashMap
'Map
(dart:_internal/cast.dart:99:46)
On Tue, 5 Jan 2021 at 13:48, Matheus H. Baumgarten notifications@github.com
wrote:
History history; does not instantiate nor have any reference to an
object, you just created a null variable, try like so:final historyList = historyBox.values.toList();final history = historyList.first; // same as calling list[0]final a = history.completedHistoryRecord;
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-754559618, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFHR7VFJWNIUU6YG5TDSYLU6PANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Unfortunately dart is not good at handling generic types like List<Map<String, dynamic>>. It's not related to hive itself but dart.
You can store List<dynamic> then cast it to Map<dynamic, dynamic> then cast items into <String, dynamic>.
import 'package:mytableqatar/data/model/completed_history_model.dart';
import 'package:mytableqatar/data/model/upcoming_history_model.dart';
import 'package:hive/hive.dart';
part 'history.g.dart';
@HiveType(typeId: 2)
class History extends HiveObject{
@HiveField(0)
final List
@HiveField(1)
final List
History(
this._upComingHistoryRecord,
this._completedHistoryRecord,
) : assert(_upComingHistoryRecord != null,
'_upComingHistoryRecord cannot be null.'),
assert(_completedHistoryRecord != null,
'_completedHistoryRecord cannot be null.');
List
return _upComingHistoryRecord.map((value) =>
UpComingHistoryRecord.fromJson(value)).toList();
}
List
return _completedHistoryRecord.map((value) =>
CompletedHistoryRecord.fromJson(value)).toList();
}
}
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'history.dart';
// ***********************
// TypeAdapterGenerator
// ***********************
class HistoryAdapter extends TypeAdapter
@override
final int typeId = 2;
@override
History read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields =
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return History(
(fields[0] as List)?.cast
(fields[1] as List)?.cast
);
}
@override
void write(BinaryWriter writer, History obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj._upComingHistoryRecord)
..writeByte(1)
..write(obj._completedHistoryRecord);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HistoryAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
Can metion the changes
On Wed, 6 Jan 2021 at 09:26, Misir Jafarov notifications@github.com wrote:
Unfortunately dart is not good at handling generic types like List
dynamic>>. It's not related to hive itself but dart. You can store List
then cast it to Map then
cast items into. โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-755110043, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFFNNNCSQBFRY3E7BSTSYP7C3ANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
I just need to store 2 models and retrieve the data from it when there is
no internet. If you dont mind pls help me i am stuck on it for a couple of
days.
On Wed, 6 Jan 2021 at 11:30, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:
import 'package:mytableqatar/data/model/completed_history_model.dart';
import 'package:mytableqatar/data/model/upcoming_history_model.dart';
import 'package:hive/hive.dart';
part 'history.g.dart';@HiveType(typeId: 2)
class History extends HiveObject{
@HiveField(0)
final List> _upComingHistoryRecord;
@HiveField(1)
final List> _completedHistoryRecord; History(
this._upComingHistoryRecord,
this._completedHistoryRecord,
) : assert(_upComingHistoryRecord != null, '_upComingHistoryRecord cannot be null.'),
assert(_completedHistoryRecord != null, '_completedHistoryRecord cannot be null.');List
get upComingHistoryRecord {
return _upComingHistoryRecord.map((value) => UpComingHistoryRecord.fromJson(value)).toList();
}List
get completedHistoryRecord {
return _completedHistoryRecord.map((value) => CompletedHistoryRecord.fromJson(value)).toList();
}
}// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'history.dart';
// ***********************
// TypeAdapterGenerator
// ***********************class HistoryAdapter extends TypeAdapter
{
@override
final int typeId = 2;@override
History read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields ={
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return History(
(fields[0] as List)?.cast>(),
(fields[1] as List)?.cast>(),
);
}@override
void write(BinaryWriter writer, History obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj._upComingHistoryRecord)
..writeByte(1)
..write(obj._completedHistoryRecord);
}@override
int get hashCode => typeId.hashCode;@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HistoryAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}Can metion the changes
On Wed, 6 Jan 2021 at 09:26, Misir Jafarov notifications@github.com
wrote:Unfortunately dart is not good at handling generic types like List
dynamic>>. It's not related to hive itself but dart. You can store List
then cast it to Map then
cast items into. โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-755110043, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFFNNNCSQBFRY3E7BSTSYP7C3ANCNFSM4VPOAP2A
.--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
[image: Screen Shot 2021-01-06 at 11.51.32 AM.png]
On Wed, 6 Jan 2021 at 11:38, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:
I just need to store 2 models and retrieve the data from it when there is
no internet. If you dont mind pls help me i am stuck on it for a couple of
days.On Wed, 6 Jan 2021 at 11:30, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:import 'package:mytableqatar/data/model/completed_history_model.dart';
import 'package:mytableqatar/data/model/upcoming_history_model.dart';
import 'package:hive/hive.dart';
part 'history.g.dart';@HiveType(typeId: 2)
class History extends HiveObject{
@HiveField(0)
final List> _upComingHistoryRecord;
@HiveField(1)
final List> _completedHistoryRecord; History(
this._upComingHistoryRecord,
this._completedHistoryRecord,
) : assert(_upComingHistoryRecord != null, '_upComingHistoryRecord cannot be null.'),
assert(_completedHistoryRecord != null, '_completedHistoryRecord cannot be null.');List
get upComingHistoryRecord {
return _upComingHistoryRecord.map((value) => UpComingHistoryRecord.fromJson(value)).toList();
}List
get completedHistoryRecord {
return _completedHistoryRecord.map((value) => CompletedHistoryRecord.fromJson(value)).toList();
}
}// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'history.dart';
// ***********************
// TypeAdapterGenerator
// ***********************class HistoryAdapter extends TypeAdapter
{
@override
final int typeId = 2;@override
History read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields ={
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return History(
(fields[0] as List)?.cast>(),
(fields[1] as List)?.cast>(),
);
}@override
void write(BinaryWriter writer, History obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj._upComingHistoryRecord)
..writeByte(1)
..write(obj._completedHistoryRecord);
}@override
int get hashCode => typeId.hashCode;@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HistoryAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}Can metion the changes
On Wed, 6 Jan 2021 at 09:26, Misir Jafarov notifications@github.com
wrote:Unfortunately dart is not good at handling generic types like List
dynamic>>. It's not related to hive itself but dart. You can store List
then cast it to Map then
cast items into. โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-755110043, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFFNNNCSQBFRY3E7BSTSYP7C3ANCNFSM4VPOAP2A
.--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
the values are there is box
On Wed, 6 Jan 2021 at 11:51, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:
[image: Screen Shot 2021-01-06 at 11.51.32 AM.png]
On Wed, 6 Jan 2021 at 11:38, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:I just need to store 2 models and retrieve the data from it when there is
no internet. If you dont mind pls help me i am stuck on it for a couple of
days.On Wed, 6 Jan 2021 at 11:30, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:import 'package:mytableqatar/data/model/completed_history_model.dart';
import 'package:mytableqatar/data/model/upcoming_history_model.dart';
import 'package:hive/hive.dart';
part 'history.g.dart';@HiveType(typeId: 2)
class History extends HiveObject{
@HiveField(0)
final List> _upComingHistoryRecord;
@HiveField(1)
final List> _completedHistoryRecord; History(
this._upComingHistoryRecord,
this._completedHistoryRecord,
) : assert(_upComingHistoryRecord != null, '_upComingHistoryRecord cannot be null.'),
assert(_completedHistoryRecord != null, '_completedHistoryRecord cannot be null.');List
get upComingHistoryRecord {
return _upComingHistoryRecord.map((value) => UpComingHistoryRecord.fromJson(value)).toList();
}List
get completedHistoryRecord {
return _completedHistoryRecord.map((value) => CompletedHistoryRecord.fromJson(value)).toList();
}
}// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'history.dart';
// ***********************
// TypeAdapterGenerator
// ***********************class HistoryAdapter extends TypeAdapter
{
@override
final int typeId = 2;@override
History read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields ={
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return History(
(fields[0] as List)?.cast>(),
(fields[1] as List)?.cast>(),
);
}@override
void write(BinaryWriter writer, History obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj._upComingHistoryRecord)
..writeByte(1)
..write(obj._completedHistoryRecord);
}@override
int get hashCode => typeId.hashCode;@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HistoryAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}Can metion the changes
On Wed, 6 Jan 2021 at 09:26, Misir Jafarov notifications@github.com
wrote:Unfortunately dart is not good at handling generic types like List
dynamic>>. It's not related to hive itself but dart. You can store List
then cast it to Map then
cast items into. โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-755110043, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFFNNNCSQBFRY3E7BSTSYP7C3ANCNFSM4VPOAP2A
.--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Could you try to modify your class like that:
@HiveType(typeId: 2)
class History extends HiveObject{
@HiveField(0)
final List<dynamic> _upComingHistoryRecord;
@HiveField(1)
final List<dynamic> _completedHistoryRecord;
History(
this._upComingHistoryRecord,
this._completedHistoryRecord,
) : assert(_upComingHistoryRecord != null,
'_upComingHistoryRecord cannot be null.'),
assert(_completedHistoryRecord != null,
'_completedHistoryRecord cannot be null.');
List<UpComingHistoryRecord> get upComingHistoryRecord {
return _upComingHistoryRecord.map((value) =>
UpComingHistoryRecord.fromJson(value as Map<String, dynamic>)).toList();
}
List<CompletedHistoryRecord> get completedHistoryRecord {
return _completedHistoryRecord.map((value) =>
CompletedHistoryRecord.fromJson(value as Map<String, dynamic>)).toList();
}
}
Same error pls subject another way pls
On Wed, 6 Jan 2021 at 12:04, Misir Jafarov notifications@github.com wrote:
Could you try to modify your class like that:
@HiveType(typeId: 2)class History extends HiveObject{
@HiveField(0)
final List_upComingHistoryRecord;
@HiveField(1)
final List_completedHistoryRecord; History(
this._upComingHistoryRecord,
this._completedHistoryRecord,
) : assert(_upComingHistoryRecord != null,'_upComingHistoryRecord cannot be null.'),
assert(_completedHistoryRecord != null,'_completedHistoryRecord cannot be null.');List
get upComingHistoryRecord {
return _upComingHistoryRecord.map((value) =>UpComingHistoryRecord.fromJson(value as Map)).toList();
}List
get completedHistoryRecord {
return _completedHistoryRecord.map((value) =>CompletedHistoryRecord.fromJson(value as Map)).toList();
}
}โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-755176221, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFAXATXPGUKHDLA7NNDSYQRSPANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
historyBox.add(History(_upComingHistoryRecord.map((value) =>
value.toJson()).toList(),_completedHistoryRecord.map((value) =>
value.toJson()).toList(),));
import 'package:mytableqatar/data/model/completed_history_model.dart';
import 'package:mytableqatar/data/model/upcoming_history_model.dart';
import 'package:hive/hive.dart';
part 'history.g.dart';
@HiveType(typeId: 2)
class History extends HiveObject{
@HiveField(0)
final List
@HiveField(1)
final List
History(
this._upComingHistoryRecord,
this._completedHistoryRecord,
) : assert(_upComingHistoryRecord != null,
'_upComingHistoryRecord cannot be null.'),
assert(_completedHistoryRecord != null,
'_completedHistoryRecord cannot be null.');
List
return _upComingHistoryRecord.map((value) =>
UpComingHistoryRecord.fromJson(value as Map
}
List
return _completedHistoryRecord.map((value) =>
CompletedHistoryRecord.fromJson(value as Map
}
}
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'history.dart';
// ***********************
// TypeAdapterGenerator
// ***********************
class HistoryAdapter extends TypeAdapter
@override
final int typeId = 2;
@override
History read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields =
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return History(
(fields[0] as List)?.cast
(fields[1] as List)?.cast
);
}
@override
void write(BinaryWriter writer, History obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj._upComingHistoryRecord)
..writeByte(1)
..write(obj._completedHistoryRecord);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HistoryAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
final historyList = historyBox.values.toList();
final history = historyList.first; // same as calling list[0]
final a = history.completedHistoryRecord;
final ab = history.upComingHistoryRecord;
the items are there in history list i just want to get it seperate thats all
On Wed, 6 Jan 2021 at 12:17, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:
Same error pls subject another way pls
On Wed, 6 Jan 2021 at 12:04, Misir Jafarov notifications@github.com
wrote:Could you try to modify your class like that:
@HiveType(typeId: 2)class History extends HiveObject{
@HiveField(0)
final List_upComingHistoryRecord;
@HiveField(1)
final List_completedHistoryRecord; History(
this._upComingHistoryRecord,
this._completedHistoryRecord,
) : assert(_upComingHistoryRecord != null,'_upComingHistoryRecord cannot be null.'),
assert(_completedHistoryRecord != null,'_completedHistoryRecord cannot be null.');List
get upComingHistoryRecord {
return _upComingHistoryRecord.map((value) =>UpComingHistoryRecord.fromJson(value as Map)).toList();
}List
get completedHistoryRecord {
return _completedHistoryRecord.map((value) =>CompletedHistoryRecord.fromJson(value as Map)).toList();
}
}โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-755176221, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFAXATXPGUKHDLA7NNDSYQRSPANCNFSM4VPOAP2A
.--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
HELLOW ANY WAY I HAVE TO DELIVER THE APPLICATION TODAY I USE THIS
EVERYWHERE PLS UNDERSTAND MY SITUATION
On Wed, 6 Jan 2021 at 12:22, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:
historyBox.add(History(_upComingHistoryRecord.map((value) =>
value.toJson()).toList(),_completedHistoryRecord.map((value) =>
value.toJson()).toList(),));import 'package:mytableqatar/data/model/completed_history_model.dart';
import 'package:mytableqatar/data/model/upcoming_history_model.dart';
import 'package:hive/hive.dart';
part 'history.g.dart';@HiveType(typeId: 2)
class History extends HiveObject{
@HiveField(0)
final List_upComingHistoryRecord;
@HiveField(1)
final List_completedHistoryRecord; History(
this._upComingHistoryRecord,
this._completedHistoryRecord,
) : assert(_upComingHistoryRecord != null, '_upComingHistoryRecord cannot be null.'),
assert(_completedHistoryRecord != null, '_completedHistoryRecord cannot be null.');List
get upComingHistoryRecord {
return _upComingHistoryRecord.map((value) =>
UpComingHistoryRecord.fromJson(value as Map)).toList();
}List
get completedHistoryRecord {
return _completedHistoryRecord.map((value) =>
CompletedHistoryRecord.fromJson(value as Map)).toList();
}
}// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'history.dart';
// ***********************
// TypeAdapterGenerator
// ***********************class HistoryAdapter extends TypeAdapter
{
@override
final int typeId = 2;@override
History read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields ={
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return History(
(fields[0] as List)?.cast>(),
(fields[1] as List)?.cast>(),
);
}@override
void write(BinaryWriter writer, History obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj._upComingHistoryRecord)
..writeByte(1)
..write(obj._completedHistoryRecord);
}@override
int get hashCode => typeId.hashCode;@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HistoryAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}final historyList = historyBox.values.toList();
final history = historyList.first; // same as calling list[0]
final a = history.completedHistoryRecord;
final ab = history.upComingHistoryRecord;the items are there in history list i just want to get it seperate thats all
On Wed, 6 Jan 2021 at 12:17, Muhammed Nazil nazil.rayaroth@gmail.com
wrote:Same error pls subject another way pls
On Wed, 6 Jan 2021 at 12:04, Misir Jafarov notifications@github.com
wrote:Could you try to modify your class like that:
@HiveType(typeId: 2)class History extends HiveObject{
@HiveField(0)
final List_upComingHistoryRecord;
@HiveField(1)
final List_completedHistoryRecord; History(
this._upComingHistoryRecord,
this._completedHistoryRecord,
) : assert(_upComingHistoryRecord != null,'_upComingHistoryRecord cannot be null.'),
assert(_completedHistoryRecord != null,'_completedHistoryRecord cannot be null.');List
get upComingHistoryRecord {
return _upComingHistoryRecord.map((value) =>UpComingHistoryRecord.fromJson(value as Map)).toList();
}List
get completedHistoryRecord {
return _completedHistoryRecord.map((value) =>CompletedHistoryRecord.fromJson(value as Map)).toList();
}
}โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-755176221, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFAXATXPGUKHDLA7NNDSYQRSPANCNFSM4VPOAP2A
.--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in--
Best wishes and regards.Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in
Try this for the getters:
List<CompletedHistoryRecord> get completedHistoryRecord {
final output = Map<String, dynamic>[];
_completedHistoryRecord.forEach((value) {
final historyRecord = value as Map<dynamic, dynamic>;
output.add(historyRecord as Map<String, dynamic>);
});
return output;
}
Do the same for UpComing.
Btw, your problem is not with Hive anymore, the errors you're getting are from dart...
Thanks for helping me. really from the bottom of my heart.
I just created a separate model and loaded it.
but we should find a proper way for these situations.
Thanks for your help with everything.
Note : I am not going to stop texting you guys.
On Wed, 6 Jan 2021 at 13:26, Matheus H. Baumgarten notifications@github.com
wrote:
Try this for the getters:
List
get completedHistoryRecord {
final output = Map[];
_completedHistoryRecord.forEach((value) {
final historyRecord = value as Map;
output.add(historyRecord as Map);
});
return output;
}Do the same for UpComing.
Btw, your problem is not with Hive anymore, the errors you're getting are
from dart...โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hivedb/hive/issues/530#issuecomment-755217395, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AJOPUFBC6ROZMMWDOFGCB53SYQ3F5ANCNFSM4VPOAP2A
.
--
Best wishes and regards.
Muhammed Nazil
MBA Information System |Mobile App Developer
Phone India: +91-8606012222
Phone Qatar: +974-3124 4266
Web: https://nazil.in