[hive_generator] not generating type adapter for freezed class
- Dominant language
- Dart
- Stars
- 4.4k
- Forks
- 449
- PR merge metrics
- No merged PRs in 30d
Description
I'm attempting to generate a type adapter for my freezed class basing myself of the examples in https://github.com/hivedb/hive/issues/225. It will generate the `DeviceStatus` adapter just fine. but not the `WledDevice` no code gets generated and no errors are thrown
``` dart
part 'wled_device.freezed.dart';
part 'wled_device.g.dart';
@HiveType(typeId: 2)
enum DeviceStatus {
@HiveField(0)
functional,
@HiveField(1)
unreachable,
@HiveField(2)
error,
}
@freezed
class WledDevice with _$WledDevice {
@ColorConverter()
@HiveType(typeId: 0, adapterName: 'WledDeviceAdapter')
const factory WledDevice({
// device IP (can also be hostname if applicable)
@HiveField(0) required String address,
// device display name ("Server Description")
@HiveField(1) required String name,
// Current connection status
@HiveField(2) @Default(DeviceStatus.functional) DeviceStatus status,
// If the light name is custom, the name returned
// by the API response will be ignored
@HiveField(3) @Default(false) bool nameIsCustom,
// if the wled device is saved to the local device
@HiveField(4) @Default(false) bool isSaved,
// Disabled devices don't get polled or show up in the list
@HiveField(5) @Default(true) bool isEnabled,
// There are two vars for brightness to discern
// API responses from slider updates
@HiveField(6) @Default(0.9) double brightness,
// the currently active device color
@HiveField(7) @Default(ColorConverter.defaultColor) @JsonKey() Color color,
}) = _WledDevice;
factory WledDevice.fromJson(Map json) =>
_$WledDeviceFromJson(json);
}
```
pubspec.yaml & build_runner output
``` yaml
name: wled
description: A cross-platform application for interacting with WLED devices
version: 1.0.0
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
auto_route: ^2.3.0
bloc: ^7.2.0-dev.3
bloc_concurrency: ^0.1.0-dev.2
flutter:
sdk: flutter
flutter_bloc: ^7.2.0
flutter_feather_icons: ^2.0.0+1
flutter_localizations:
sdk: flutter
freezed_annotation: ^0.14.3
get_it: ^7.2.0
hive: ^2.0.4
hive_flutter: ^1.1.0
http: ^0.13.3
injectable: ^1.5.0
json_annotation: ^4.1.0
multicast_dns: ^0.3.1
rive: ^0.7.28
rxdart: ^0.27.2
sleek_circular_slider: ^2.0.1
webview_flutter: ^2.0.14
xml: ^5.1.0
dev_dependencies:
auto_route_generator: ^2.3.0
build_runner: ^2.1.2
flutter_app_name: ^0.1.0
flutter_launcher_icons: "^0.9.2"
flutter_native_splash: ^1.2.3
freezed: ^0.14.5
hive_generator: ^1.1.1
injectable_generator: ^1.5.1
json_serializable: ^5.0.1
very_good_analysis: ^2.3.0
dependency_overrides:
meta: ^1.7.0
flutter:
uses-material-design: true
assets:
- assets/rive/
fonts:
- family: Nunito
fonts:
- asset: fonts/Nunito-Bold.ttf
weight: 700
- asset: fonts/Nunito-Regular.ttf
weight: 400
# internationalization settings
flutter_intl:
enabled: true
class_name: Localization
arb_dir: lib/core/l10n
output_dir: lib/core/l10n/generated
# set flutter splash screen
flutter_native_splash:
color: "#1D1D1D"
image: assets/images/splash.png
fullscreen: true
android12: false
# set flutter app icon
flutter_icons:
ios: true
android: true
image_path_ios: "assets/images/fallback.png"
image_path_android: "assets/images/fallback.png"
adaptive_icon_background: "assets/images/background.png"
adaptive_icon_foreground: "assets/images/foreground.png"
# set flutter app name
flutter_app_name:
name: "WLED"
```
``` powershell
flutter pub run build_runner build --delete-confl
[INFO] Generating build script...
[INFO] Generating build script completed, took 1.0s
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 1.3s
[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 7.8s
[INFO] Running build...
[INFO] 1.2s elapsed, 0/10 actions completed.
[INFO] 2.6s elapsed, 1/10 actions completed.
[INFO] 3.8s elapsed, 1/10 actions completed.
[INFO] 4.8s elapsed, 1/10 actions completed.
[INFO] 5.8s elapsed, 1/10 actions completed.
[INFO] 6.9s elapsed, 1/10 actions completed.
[INFO] 23.2s elapsed, 1/10 actions completed.
[WARNING] No actions completed for 21.4s, waiting on:
- hive_generator:hive_generator on lib/core/app/app_router.dart
- hive_generator:hive_generator on lib/features/device_control/bloc/
- hive_generator:hive_generator on lib/features/device_add/bloc/devi
- hive_generator:hive_generator on lib/features/device_add/data/repo
- hive_generator:hive_generator on lib/core/data/models/wled_device.
.. and 4 more
[INFO] 24.4s elapsed, 12/15 actions completed.
[INFO] 25.4s elapsed, 20/20 actions completed.
[INFO] 26.5s elapsed, 23/31 actions completed.
[WARNING] json_serializable:json_serializable on lib/core/data/models/
The constructor parameter for `status` has a default value `DeviceStat[WARNING] json_serializable:json_serializable on lib/core/data/models/
The constructor parameter for `nameIsCustom` has a default value `fals
[WARNING] json_serializable:json_serializable on lib/core/data/models/
The constructor parameter for `isSaved` has a default value `false`, b
[WARNING] json_serializable:json_serializable on lib/core/data/models/
The constructor parameter for `isEnabled` has a default value `true`,
[WARNING] json_serializable:json_serializable on lib/core/data/models/
The constructor parameter for `brightness` has a default value `0.9`,
[INFO] 28.1s elapsed, 31/31 actions completed.
[INFO] 29.2s elapsed, 34/42 actions completed.
[INFO] 30.2s elapsed, 36/43 actions completed.
[WARNING] auto_route_generator:autoRouteGenerator on lib/core/app/app_
WARNING => Because [DeviceControlView] has required parameters (device
@PathParam() and @QueryParam() annotations will be ignored.
[INFO] 31.6s elapsed, 43/55 actions completed.
[INFO] 32.8s elapsed, 48/63 actions completed.
[INFO] 34.0s elapsed, 61/70 actions completed.
[INFO] 35.3s elapsed, 73/82 actions completed.
[WARNING] injectable_generator:injectable_config_builder on lib/core/a
Missing dependencies in wled/core/app/app_injector.dart
[DeviceAddBloc] depends on unregistered type [AppRouter] from package:
Did you forget to annotate the above class(s) or their implementation with @injectable?
or add the right environment keys?
------------------------------------------------------------------------
[INFO] Running build completed, took 35.5s
[INFO] Caching finalized dependency graph...
[INFO] 36.5s elapsed, 82/82 actions completed.
[INFO] Caching finalized dependency graph completed, took 1.2s
[INFO] Succeeded after 36.7s with 16 outputs (82 actions)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.