Skip to content

Commit

Permalink
refactor: updated to use cascade notation on generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
kishormainali committed Feb 20, 2024
1 parent 121833a commit 5005ac5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.0.4
- updated to use cascade notation on generated code

# 1.0.3
- added type parameter on `registerAdapter` method
- updated min dart sdk version to 3.2.6
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Add the following to your pubspec.yaml file:

```yaml
dev_dependencies:
hive_generator: latest
type_register: latest
```
Expand Down Expand Up @@ -41,7 +42,7 @@ import 'package:example/model.dart';
import 'package:hive_local_storage/hive_local_storage.dart';
void registerAdapters() {
Hive.registerAdapter(AnotherModelAdapter());
Hive.registerAdapter(ModelAdapter());
Hive..registerAdapter<AnotherModel>(AnotherModelAdapter())
..registerAdapter<Model>(ModelAdapter());
}
```
7 changes: 4 additions & 3 deletions example/lib/src/core/register_adapters.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/src/type_register_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class TypeRegisterBuilder implements Builder {
..body.addAll(
[
const Code('void registerAdapters(){'),
...files.map((file) => Code('Hive.registerAdapter<${file.name}>(${file.adapterName}());')),
const Code('Hive'),
...files.map((file) => Code('..registerAdapter<${file.name}>(${file.adapterName}())')),
const Code(';'),
const Code('}'),
],
),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: type_register
description: Generator which generates method named registerAdapters with all the hive adapters for the types annotated with @HiveType.
version: 1.0.3
version: 1.0.4
topics:
- type-register-generator
- dart
Expand Down

0 comments on commit 5005ac5

Please sign in to comment.