DecklanOrie
DecklanOrie

Reputation: 33

$ flutter pub run build_runner build in project with hive not responding

When run $ flutter pub run build_runner build in project with hive, it just stops here(i have even waited 2 hours and its not going any further), i have tried creating a new project specifically for hive implementation. but its the same issue

[INFO] Generating build script...
[INFO] Generating build script completed, took 528ms
[WARNING] Deleted previous snapshot due to missing asset graph.
[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 21.3s
[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 1.2s
[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 2ms
[INFO] Running build...
[INFO] Generating SDK summary...

this is my class:

import 'package:hive/hive.dart';

part 'person.g.dart';

@HiveType(typeId: 0)
class Person extends HiveObject {
  @HiveField(0)
  int id;
  @HiveField(1)
  String name;
  @HiveField(2)
  DateTime birthDate;
  Person(this.id, this.name, this.birthDate);
}

and my pubspec.yaml file:

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  hive:
  hive_flutter:
  path_provider:

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.3

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner:
  hive_generator:


flutter:

  

Upvotes: 3

Views: 8955

Answers (4)

The Gorilla
The Gorilla

Reputation: 11

In my case,

I was missing the hive_generator package in my pubspe.yaml's dev_dependencies .

Upvotes: 1

Hassan
Hassan

Reputation: 500

Flutter pub run is deprecated
now in 2024
open terminal and enter:

dart run build_runner build  

for more Build-in commands read build_runner document at https://pub.dev/packages/build_runner

Upvotes: 0

arthur_jose
arthur_jose

Reputation: 1

if (dart run build_runner build) not work

(add your file_name.g.dart)eg=> part 'model.g.dart'; in top

and run in terminal

flutter packages pub run build_runner watch --use-polling-watcher --delete-conflicting-outputs

Upvotes: 0

Mukul
Mukul

Reputation: 1155

I Was Also facing the same issue and solved it with,

flutter pub upgrade

If that doesn't help you, then try these steps too

flutter clean

flutter pub get

flutter packages pub run build_runner build --delete-conflicting-outputs  

Upvotes: 5

Related Questions