isar / isar/hive

Unable to compile Flutter if `import 'package:hive_flutter/hive_flutter.dart';`

Open
#646 1 comment 0 reactions 1 assignee Claimed by @simc View on GitHub
problem
Dominant language
Dart
Stars
4.4k
Forks
449
PR merge metrics
No merged PRs in 30d

Description

**Steps to Reproduce**
As long as this line: `import 'package:hive_flutter/hive_flutter.dart';` exists in source code, the code will not compile.

Developer Environment:
- Windows 10 x64 20H2
- Android Studio 4.1.3

Compiled against:
- Android
- Web

```shell
Launching lib\rido\screens\shopping_list_screen.dart on Edge in debug mode...
Waiting for connection from debug service on Edge...
../../AppData/Local/Android/flutter/.pub-cache/hosted/pub.dartlang.org/hive_flutter-1.0.0/lib/src/box_extensions.dart: Error: The control character U+0000 can only be used in strings and comments.
../../AppData/Local/Android/flutter/.pub-cache/hosted/pub.dartlang.org/hive_flutter-1.0.0/lib/src/watch_box_builder.dart: Error: The control character U+0000 can only be used in strings and comments.
../../AppData/Local/Android/flutter/.pub-cache/hosted/pub.dartlang.org/hive_flutter-1.0.0/lib/hive_flutter.dart:11:6: Error: Can't use '../../AppData/Local/Android/flutter/.pub-cache/hosted/pub.dartlang.org/hive_flutter-1.0.0/lib/src/box_extensions.dart' as a part, because it has no 'part of' declaration.
part 'src/box_extensions.dart';
^
../../AppData/Local/Android/flutter/.pub-cache/hosted/pub.dartlang.org/hive_flutter-1.0.0/lib/hive_flutter.dart:13:6: Error: Can't use '../../AppData/Local/Android/flutter/.pub-cache/hosted/pub.dartlang.org/hive_flutter-1.0.0/lib/src/watch_box_builder.dart' as a part, because it has no 'part of' declaration.
part 'src/watch_box_builder.dart';
^
Unhandled exception:
NoSuchMethodError: The getter 'scheme' was called on null.
Receiver: null
Tried calling: scheme
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1 urlForComponentUri (package:frontend_server/src/javascript_bundle.dart:204:61)
#2 JavaScriptBundler.compile (package:frontend_server/src/javascript_bundle.dart:121:27)

#3 FrontendCompiler.writeJavascriptBundle (package:frontend_server/frontend_server.dart:632:5)

#4 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:545:9)

#5 listenAndCompile. (package:frontend_server/frontend_server.dart:1105:11)

Finished with error: the Dart compiler exited unexpectedly.
Failed to compile application.
```

**Code sample**
```yaml
// pubspec.yaml
environment:
sdk: ">=2.7.0 <3.0.0"

dependencies:
flutter:
sdk: flutter

provider: ^5.0.0
flutter_bloc: ^7.0.0
webview_flutter: ^2.0.4
hive: ^2.0.4
hive_flutter: ^1.0.0

dev_dependencies:
flutter_test:
sdk: flutter
hive_generator: ^1.1.0
build_runner: ^2.0.1
```
```dart
// main.dart
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:myflutter/rido/components/shopping_list_item.dart';
import 'package:myflutter/rido/models/product.dart';

class ShoppingList extends StatelessWidget { ... }
```

**Version**
- Platform: Android, Web
- Flutter version: 2.0.5
- Hive version: 2.0.4

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.