Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter : Could not find package "build_runner"

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

like image 825
Zeffry Reynando Avatar asked Dec 18 '19 02:12

Zeffry Reynando


People also ask

Why my build_runner build failed in flutter?

This error is basically caused by the auto formatter removing the line like below. In this article, We have a walkthrough How to Solve Pub Run build_runner build Failed In Flutter? Thanks for Reading !!! Keep Learning !!! Keep Fluttering !!! FlutterAgency.com is our portal Platform dedicated to Flutter Technology and Flutter Developers.

How do I use the build_runner package?

The build_runner package exposes a binary by the same name, which can be invoked using dart run build_runner <command>. The available commands are build, watch, serve, and test. build: Runs a single build and exits. watch: Runs a persistent build server that watches the files system for edits and does rebuilds as necessary.

What is the difference between version and build number in flutter?

# A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively.

How do I use the build_runner package in Dart?

The build_runner package exposes a binary by the same name, which can be invoked using dart run build_runner <command>. The available commands are build, watch, serve, and test.


2 Answers

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

like image 120
vids Avatar answered Nov 15 '22 21:11

vids


You can try the code below:

flutter packages pub run build_runner build
like image 28
batuhankrbb Avatar answered Nov 15 '22 20:11

batuhankrbb