Steps to Reproduce
@HiveType()
class Client extends HiveObject {
@HiveField(0)
String descricaoApp;
@HiveField(1)
int dataCriacao;
}
Code sample
file Client.g.dart
Missing concrete implementation of 'getter TypeAdapter.typeId'.
Try implementing the missing method, or make the class abstract.
my pubspack hive imports
hive: ^1.4.1+1
hive_flutter: any
path_provider: any
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^1.3.1
hive_generator: any
mobx_codegen: ^1.0.2
moor_generator: ^2.4.0
retrofit_generator:
Yes i have the same problem. I tried adding typeId @HiveType(typeId : 0) still not working.
I went around and maintained following for all models
```
@HiveType(typeId: 1)
class Account extends HiveObject {
static const int typeId = 1;
...
}
class AccountAdapter extends TypeAdapter
...
@override
int get typeId => Account.typeId;
}
````
Although this can't be acquired in enum types, as such declarations are not possible in enum, hence had to manually return _typeId_ value in that case.
I followed solution provided by Mravuri at here, it worked for me.
I went around and maintained following for all models
@HiveType(typeId: 1) class Account extends HiveObject { static const int typeId = 1; ... } class AccountAdapter extends TypeAdapter<Account> { ... @override int get typeId => Account.typeId; }Although this can't be acquired in enum types, as such declarations are not possible in enum, hence had to manually return _typeId_ value in that case.
I followed solution provided by Mravuri at
here, it worked for me.
Any manual changes to generated adapters will be wiped off on new build runner build or watch, so need a possible fixture.
Secondly for this to be implemented, typeid should be made compulsory for given Annotation of HiveType as autogeneration won't be possible whilst migration or new generation as *.g.dart get deleted for new generation.
I am also having the same problem. I need to see version control for typeId in each model and adding it manually each time after running the build_runner. Will this issue fixed soon?
Can confirm that the problem is happening on my machine also with a new install of hive.
It works for me with the latest versions. This is what I have in my pubspec.yaml:
dependencies:
hive: ^1.4.1+1
dev_dependencies:
hive_generator: ^0.7.0+2
I used the decorator like this @HiveType(typeId: 33)
(The Hive docs need to be updated , BTW. The typeId argument isn't mentioned.)
This field appeared in the generated code, in the .g.dart file :
@override
final typeId = 33;
Don't forget to run flutter pub run build_runner build to generate the code.
If you have modified the .g.dart file by hand, you should delete it first, otherwise it may not get updated (at least it didn't for me).
hive_generator: ^0.7.0+2
This gives me the following error when I do pub get
Because hive_generator >=0.6.0 depends on dartx ^0.2.0 which depends on quiver >=2.0.3 <2.1.0, hive_generator >=0.6.0 requires quiver >=2.0.3 <2.1.0.
And because every version of flutter_test from sdk depends on quiver 2.1.3, hive_generator >=0.6.0 is incompatible with flutter_test from sdk.
So, because paster depends on both flutter_test any from sdk and hive_generator ^0.7.0+2, version solving failed.
pub get failed (1; So, because paster depends on both flutter_test any from sdk and hive_generator ^0.7.0+2, version solving failed.)
This commit needs to be released https://github.com/hivedb/hive/commit/e90a7d940cc904eb335f35d59cca251cb810ae2d
However seems some tests are failing
Same issue here, build won't generate the typeId unless I raise the hive_generator version to 0.7.0+2. But the version bump forces me to drop the flutter_test dependency.
Can we expect a fix in the near future?
The issue fixed in updated version of hive_generator.

Use exactly these versions for better results
Most helpful comment
It works for me with the latest versions. This is what I have in my pubspec.yaml:
I used the decorator like this
@HiveType(typeId: 33)(The Hive docs need to be updated , BTW. The
typeIdargument isn't mentioned.)This field appeared in the generated code, in the .g.dart file :
Don't forget to run
flutter pub run build_runner buildto generate the code.If you have modified the .g.dart file by hand, you should delete it first, otherwise it may not get updated (at least it didn't for me).