我只是想用我 3 个月前存储的相同命令来生成我的文件(我对后端和 devops 不太擅长),现在它不再生成文件了。它告诉我使用我不记得的删除命令,但即使使用该命令,我的文件仍然不会生成。这就是我的日志的样子,您可以在下面找到一个简单类的代码。
我的猜测之一是这与我更改 github 帐户有关,因为提到了权限问题。
我在 Windows 10 中使用 vs 代码。
日志文件:
E:\1 Work\flutter_pilot> flutter pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 336ms
[WARNING] Deleted previous snapshot due to missing asset graph.
[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 12.5s
[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 787ms
[INFO] Checking for unexpected pre-existing outputs....
[INFO] Found 13 …Run Code Online (Sandbox Code Playgroud) 我已经添加// @dart=2.9到我的所有文件中,但build_runner不会在不抛出此错误的情况下做它的事情:
Warning: Operand of null-aware operation '?.' has type 'SendPort' which excludes null. - 'SendPort' is from 'dart:isolate'. sendPort?.send(result); ^Error: Cannot run with sound null safety, because the following dependencies don't support null safety:
- package:build_runner_core
- package:json_serializable
- package:moor_generator
- package:objectbox_generator
- package:retrofit_generator
- package:source_gen
- package:build_config
- package:build_runner
- package:build
- package:json_annotation
- package:glob
- package:pool
- package:crypto
- package:logging
- package:watcher
- package:build_resolvers
- package:timing
- package:graphs
- package:package_config
- package:yaml
- …Run Code Online (Sandbox Code Playgroud) 当我运行 build_runner 命令时,它显示以下错误:
Failed to build build_runner:build_runner:
../../.pub-cache/hosted/pub.dev/dart_style-2.3.5/lib/src/front_end/ast_node_visitor.dart:251:16: Error: The getter 'macroKeyword' isn't defined for the class 'ClassDeclaration'.
- 'ClassDeclaration' is from 'package:analyzer/src/dart/ast/ast.dart' ('../../.pub-cache/hosted/pub.dev/analyzer-6.2.0/lib/src/dart/ast/ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'macroKeyword'.
node.macroKeyword,
^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/dart_style-2.3.5/lib/src/source_visitor.dart:595:19: Error: The getter 'macroKeyword' isn't defined for the class 'ClassDeclaration'.
- 'ClassDeclaration' is from 'package:analyzer/src/dart/ast/ast.dart' ('../../.pub-cache/hosted/pub.dev/analyzer-6.2.0/lib/src/dart/ast/ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named …Run Code Online (Sandbox Code Playgroud) 我运行flutter packages pug run build_runner build在 Flutter 中创建 TypeAdapter 的普通命令,但出现以下错误:
类型“UnspecifiedInvalidResult”不是类型转换中类型“LibraryElementResult”的子类型
它说它在以下文件中发现了错误:
import 'dart:core';
import 'package:hive/hive.dart';
part 'storedItem.g.dart';
@HiveType(typeId: 1)
class Person extends HiveObject {
@HiveField(0)
String name;
@HiveField(1)
int age;
Person({required this.name, required this.age});
}
Run Code Online (Sandbox Code Playgroud)
我的意思是这就是文档的代码!我做错了什么?
顺便说一句:在 M1 MacBook Air、Flutter 2.2.3、Android Studio 4.2.2 上进行开发
使用 Mockito 包运行 build_runner 来生成模拟失败。
终端输出:
[INFO] 正在生成构建脚本... [INFO] 生成构建脚本已完成,耗时 2.2 秒
[信息] 预编译构建脚本...... [警告] /D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3.0/lib/src/ builder.dart:412:19:错误:没有为类“LibraryElement”定义吸气剂“libraryExports”。
- 'LibraryElement'来自'package:analyzer/dart/element/element.dart' ('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1 /lib/dart/element/element.dart')。尝试将名称更正为现有 getter 的名称,或定义名为“libraryExports”的 getter 或字段。...entryLib.libraryExports,^^^^^^^^^^^^^^^ /D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3。 0/lib/src/builder.dart:413:19:错误:没有为类“LibraryElement”定义吸气剂“libraryImports”。
- 'LibraryElement'来自'package:analyzer/dart/element/element.dart' ('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1 /lib/dart/element/element.dart')。尝试将名称更正为现有 getter 的名称,或定义名为“libraryImports”的 getter 或字段。...entryLib.libraryImports,^^^^^^^^^^^^^^/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3。 0/lib/src/builder.dart:1493:36:错误:没有为类“ParameterElement”定义吸气剂“enendingElement2”。
- 'ParameterElement'来自'package:analyzer/dart/element/element.dart' ('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1 /lib/dart/element/element.dart')。尝试将名称更正为现有 getter 的名称,或定义名为“enendingElement2”的 getter 或字段。最终方法=parameter.enendingElement2!; ^^^^^^^^^^^^^^^^^^ /D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3.0/lib/ src/builder.dart:1524:30:错误:没有为类“ParameterElement”定义吸气剂“enendingElement2”。
- 'ParameterElement'来自'package:analyzer/dart/element/element.dart' ('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1 /lib/dart/element/element.dart')。尝试将名称更正为现有 getter 的名称,或定义名为“enendingElement2”的 getter 或字段。最终方法=parameter.enendingElement2 as MethodElement; ^^^^^^^^^^^^^^^^^^ /D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3.0/lib/ src/builder.dart:1525:27:错误:没有为类“MethodElement”定义吸气剂“enendingElement2”。
- 'MethodElement'来自'package:analyzer/dart/element/element.dart' ('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1 /lib/dart/element/element.dart')。尝试将名称更正为现有 getter 的名称,或定义名为“enendingElement2”的 getter 或字段。Final class_ = method.enendingElement2 as ClassElement; ^^^^^^^^^^^^^^^^^^ /D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3.0/lib/ src/builder.dart:1535:28:错误:没有为类“ExecutableElement”定义吸气剂“enendingElement2”。
- 'ExecutableElement' 来自 'package:analyzer/dart/element/element.dart' ('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1 /lib/dart/element/element.dart')。尝试将名称更正为现有 getter 的名称,或定义名为“enendingElement2”的 getter 或字段。overridedenMethod.enshingElement2 …
当我运行时flutter pub run build_runner build --delete-conflicting-outputs,我收到此错误:
Deprecated. Use `dart run` instead.
[INFO] Generating build script completed, took 169ms
[WARNING] ../../../.pub-cache/hosted/pub.dev/built_value_generator-8.6.1/lib/src/dart_types.dart:65:21: Error: 'InvalidType' isn't a type.
if (dartType is InvalidType) {
^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dev/built_value_generator-8.6.1/lib/src/value_source_class.dart:497:20: Error: The getter 'name2' isn't defined for the class 'NamedType'.
- 'NamedType' is from 'package:analyzer/dart/ast/ast.dart' ('../../../.pub-cache/hosted/pub.dev/analyzer-5.7.1/lib/dart/ast/ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'name2'.
if (type.name2.lexeme == 'Built') {
^^^^^
[INFO] Precompiling build script... completed, …Run Code Online (Sandbox Code Playgroud) 问题陈述:
我正在使用build_runner包构建一个代码生成器。
我运行flutter pub run build_runner build来执行我的代码生成器。
问题:
如何flutter pub run build_runner build使用断点进行调试?
类似问题:
如何在intellij idea中以调试模式运行flutter'packages pub run build_runner build'?
我想在我的生成器代码上放置断点,但我不知道如何在调试模式下运行该命令。
我使用source_gen和编写了生成器build_runner
class MyGenerator extends GeneratorForAnnotation<Todo> {
@override
FutureOr<String> generateForAnnotatedElement(
Element element, ConstantReader annotation, BuildStep buildStep) {
return "// Hey! Annotation found!";
}
}
Run Code Online (Sandbox Code Playgroud) 运行后 flutter pub run build_runner watch --delete-conflicting-outputs
构建运行器输出
$ flutter pub run build_runner watch --delete-conflicting-outputs
[INFO] Generating build script...
[INFO] Generating build script completed, took 402ms
[WARNING] Deleted previous snapshot due to missing asset graph.
[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 11.7s
[INFO] Setting up file watchers...
[INFO] Setting up file watchers completed, took 18ms
[INFO] Waiting for all file watchers to be ready...
[INFO] Waiting for all file watchers to be ready completed, …Run Code Online (Sandbox Code Playgroud) 编辑 3这一定是font_awesome_flutter问题。当我离开dependency_overrides但pubspec.yaml删除 font_awesome_flutter 参数时,只需执行以下操作:
dependency_overrides:
Run Code Online (Sandbox Code Playgroud)
有用。
我升级到 flutter 2.0,现在当我尝试运行时出现此错误flutter pub run build_runner watch --delete-conflicting-outputs:
The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated, please run "pub get" again.
pub finished with exit code 65
Run Code Online (Sandbox Code Playgroud)
知道如何修复吗?我已经跑过很多次flutter pub get了pub get。
pubspec.yaml:
name: vepo
description: The Vepo mobile app.
publish_to: "none"
version: 1.0.0+1
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
animate_do: ^2.0.0
cloud_firestore: ^1.0.1
dio: ^4.0.0
enum_to_string: …Run Code Online (Sandbox Code Playgroud) build-runner ×10
dart ×10
flutter ×10
dart-pub ×2
build ×1
built-value ×1
flutter-hive ×1
mockito ×1