type_register 1.0.5 copy "type_register: ^1.0.5" to clipboard
type_register: ^1.0.5 copied to clipboard

Generator which generates method named registerAdapters with all the hive adapters for the types annotated with @HiveType.

Type Register Generator #

pub package

Code generator for creating helper functions for registering Hive types. It will generate method named registerAdapters with all the hive adapters for the types annotated with @HiveType.

Getting Started #

Add the following to your pubspec.yaml file:

dev_dependencies:
  hive_generator: latest
  type_register: latest

Then run the following command: #

dart run build_runner build -d

By default it will generate a file named register_adapters.dart inside lib folder.

if you want to change the output location create build.yaml file in the root of your project and add the following:

targets:
  $default:
    builders:
      type_register|type_register:
        options:
          output_path: lib/src/core/

Output #

register_adapters.dart

import 'package:example/another_model.dart';
import 'package:example/model.dart';
import 'package:hive_local_storage/hive_local_storage.dart'; 

void registerAdapters() {
  Hive..registerAdapter<AnotherModel>(AnotherModelAdapter())
      ..registerAdapter<Model>(ModelAdapter());
}
1
likes
160
pub points
0%
popularity

Publisher

verified publisherkishormainali.com

Generator which generates method named registerAdapters with all the hive adapters for the types annotated with @HiveType.

Repository (GitHub)
View/report issues

Topics

#type-register-generator #dart #hive #hive-adapters #utilities

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, build, code_builder, dart_style, equatable, glob, hive, path, source_gen, yaml

More

Packages that depend on type_register