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.
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.
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.
# 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.
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.
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
You can try the code below:
flutter packages pub run build_runner build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With