26

I work with Hive Packages, I implement Modularization in my project. first i create packages with name network with run command flutter create --template=package network, I reference this.

This packages include models of my project. after that I create model user, then run command build the model flutter packages pub run build_runner build --delete-conflicting-outputs:

import 'package:hive/hive.dart';

part 'user_model_hive.g.dart';

@HiveType()
class UserModelHive extends HiveObject {
  @HiveField(0) 
  DateTime id;
  @HiveField(1)
  String giverName;
  @HiveField(2)
  String pinCodeNumber;

  UserModelHive({this.id, this.giverName, this.pinCodeNumber});
}

But I get error like this

Could not find package "build_runner". Did you forget to add a dependency? pub finished with exit code 65

I'm sure already include build_runner in my packages network.

pubspec.yaml

name: network
description: A new Flutter package project.
version: 0.0.1
author:
homepage:

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  hive: ^1.1.1
  hive_flutter: ^0.2.1
dev_dependencies:
  flutter_test:
    sdk: flutter
  hive_generator: ^0.5.2
  build_runner: ^1.7.2

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:
  # To add assets to your package, add an assets section, like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg
  #
  # For details regarding assets in packages, see
  # https://flutter.dev/assets-and-images/#from-packages
  #
  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.
  # To add custom fonts to your package, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts in packages, see
  # https://flutter.dev/custom-fonts/#from-packages

I'm already use this command but nothing happens: flutter packages get & flutter pub get

It's my structure folder if you needed. my structure folder

padaleiana
  • 955
  • 1
  • 14
  • 23
Zeffry Reynando
  • 3,445
  • 12
  • 49
  • 89

8 Answers8

25

I also got the same error. I have resolved it by adding build_runner in dev_depndencies, in pubspec.yaml file like:

dev_dependencies:
    build_runner: ^1.3.1
    mobx_codegen: ^0.3.9
dKen
  • 3,078
  • 1
  • 28
  • 37
vids
  • 381
  • 3
  • 5
7

You can try the code below:

flutter packages pub run build_runner build
batuhankrbb
  • 598
  • 7
  • 10
3

As mentioned in the GitHub issue posted shared in the comments, the issue was caused by running the app from a different directory. In this case, the app was being run on root in the issue posted. The issue has been solved by running the app from /network.

Omatt
  • 8,564
  • 2
  • 42
  • 144
2

Run this commands in your terminal:

flutter clean
flutter pub get
flutter packages pub run build_runner build --delete-conflicting-outputs
Darkhorse
  • 186
  • 2
  • 7
1

I solved this by doing these things

  1. Adding build_runner in dev dependencies
  2. Converting @HiveType(0) to @HiveType(typeId: 0)

After this run these comman

flutter clean 
flutter pub get 
flutter packages pub run build_runner build
0

I have faced to this issue

I change my model class @HiveType() annotation

@HiveType(0) 

Like that.Problem solved.

(I was posting here for future developers who faced to this)

Anushka Pubudu
  • 389
  • 3
  • 10
0

This happened to me when I ran flutter pub run build-runner build --delete-conflicting-outputs.

The issue is that I've been writing build-runner and not build_runner

Ahmad Hamwi
  • 204
  • 2
  • 10
-1

I add build_runner into dev dependency and run this command :

flutter packages pub run build_runner build