isar / isar/hive

Error to generate adapter using flutter 2

Open
#678 1 comment 0 reactions 0 assignees View on GitHub
problem
Dominant language
Dart
Stars
4.4k
Forks
449
PR merge metrics
No merged PRs in 30d

Description

**Steps to Reproduce**
Hello I am working with flutter 2 and when I try to generate my adapter with the command I get this.

**Code sample. My Adapter**
```
import 'package:hive/hive.dart';

part 'user_preferences.g.dart';

@HiveType(typeId: 1)
class UserPreferences extends HiveObject {
@HiveField(0)
String? fullName;

@HiveField(1)
String? email;

@HiveField(2)
bool isDark = false;

@HiveField(3)
String? token;
}

```

**Version**
- Platform: iOS, Android, Mac, Windows, Linux, Web
- Flutter version: [2.2.0]
- Hive version: [2.0.4]

```flutter packages pub run build_runner build```

```
Changing current working directory to: /Users/pzenteno/projects/flutter/wingchun_app
Failed to precompile build_runner:build_runner:
../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:1600:40: Error: Getter not found: 'topLevelVariable'.
return kinds.contains(TargetKind.topLevelVariable);
^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2024:23: Error: Getter not found: 'topLevelVariable'.
case TargetKind.topLevelVariable:
^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2024:23: Error: Type 'dynamic' of the case expression is not a subtype of type 'TargetKind' of this switch expression.
- 'TargetKind' is from 'package:meta/meta_meta.dart' ('../../../.pub-cache/hosted/pub.dartlang.org/meta-1.3.0/lib/meta_meta.dart').
case TargetKind.topLevelVariable:
^
../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2001:13: Context: The switch expression is here.
switch (this) {
^
```
pub finished with exit code 1

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing `flutter packages pub run build_runner build` with Flutter 2.2.0, Hive 2.0.4, and the shown adapter. Inspect the analyzer and meta versions named in the precompile error. Done means adapter generation completes without the `TargetKind.topLevelVariable` errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
build-system, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.