Problem while flutter build runner register generator for using the hive database in flutter
3,295
worked for me after upgrading build_runner to
hive_generator: ^1.1.1
build_runner: ^2.0.5
Author by
Vaibhav Mali
Updated on December 20, 2022Comments
-
Vaibhav Mali over 1 year
I am getting below error while generating .g.dart file by build runner command. Could you please help to figure out what's wrong here?
[INFO] Creating build script snapshot...... [INFO] Creating build script snapshot... completed, took 6.8s [SEVERE] Failed to snapshot build script .dart_tool/build/entrypoint/build.dart. This is likely caused by a misconfigured builder definition. [SEVERE] ../../../vaibhav/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.1+1/lib/src/registry/type_registry_impl.dart:14:7: Error: The non-abstract class 'TypeRegistryImpl' is missing implementations for these members: - TypeRegistry.noTry to either - provide an implementation, - inherit an implementation from a superclass or mixin, - mark the class as abstract, or - provide a 'noSuchMethod' implementation.class TypeRegistryImpl implements TypeRegistry { ^^^^^^^^^^^^^^^^../../../vaibhav/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.1+1/lib/src/registry/type_registry.dart:7:7: Context: 'TypeRegistry.no' is defined here. int no; ^^../../../vaibhav/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.1+1/lib/src/hive_impl.dart:21:7: Error: The non-abstract class 'HiveImpl' is missing implementations for these members: - TypeRegistry.noTry to either - provide an implementation, - inherit an implementation from a superclass or mixin, - mark the class as abstract, or - provide a 'noSuchMethod' implementation.class HiveImpl extends TypeRegistryImpl implements HiveInterface { ^^^^^^^^../../../vaibhav/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.1+1/lib/src/registry/type_registry.dart:7:7: Context: 'TypeRegistry.no' is defined here. int no; ^^../../../vaibhav/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.1+1/lib/src/registry/type_registry_impl.dart:35:8: Error: The method 'TypeRegistryImpl.registerAdapter' has fewer positional arguments than those of overridden method 'TypeRegistry.registerAdapter'. void registerAdapter<T>(TypeAdapter<T> adapter, {bool internal = false}) { ^../../../vaibhav/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.1+1/lib/src/registry/type_registry.dart:9:8: Context: This is the overridden method ('registerAdapter'). void registerAdapter<T>(TypeAdapter<T> adapter,int no); ^../../../vaibhav/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.1+1/lib/src/hive_impl.dart:21:7: Error: The implementation of 'registerAdapter' in the non-abstract class 'HiveImpl' does not conform to its interface.class HiveImpl extends TypeRegistryImpl implements HiveInterface { ^^^^^^^^../../../vaibhav/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.1+1/lib/src/registry/type_registry_impl.dart:35:8: Context: The method 'TypeRegistryImpl.registerAdapter' has fewer positional arguments than those of overridden method 'TypeRegistry.registerAdapter'. void registerAdapter<T>(TypeAdapter<T> adapter, {bool internal = false}) { ^../../../vaibhav/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.1+1/lib/src/registry/type_registry.dart:9:8: Context: This is the overridden method ('registerAdapter'). void registerAdapter<T>(TypeAdapter<T> adapter,int no); ^../../../vaibhav/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.1+1/lib/src/hive_impl.dart:21:7: Error: Class 'HiveImpl' inherits multiple members named 'registerAdapter' with incompatible signatures.Try adding a declaration of 'registerAdapter' to 'HiveImpl'.class HiveImpl extends TypeRegistryImpl implements HiveInterface { ^^^^^^^^ pub finished with exit code 78
This is my pubspec.yaml
description: A new Flutter application. version: 1.0.0+1 environment: sdk: ">=2.2.0 <3.0.0" dependencies: flutter: sdk: flutter hive: ^1.4.1+1 hive_flutter: ^0.3.0+2 path_provider: ^1.6.5 cupertino_icons: ^0.1.2 dev_dependencies: flutter_test: sdk: flutter hive_generator: ^0.7.0+2 build_runner: ^1.8.0 flutter: uses-material-design: true```
-
Vaibhav Mali almost 4 yearsimport 'package:hive/hive.dart'; part 'person.model.g.dart'; @HiveType(typeId: 1) class PersonModel{ @HiveField(0) int id; @HiveField(1) String name; @HiveField(2) DateTime birthDate; PersonModel(this.id, this.name, this.birthDate); }
-