我正在尝试使用我自己编写的源代码生成包,称为animated_widget_generator
. 调用 annotations 包,并调用animated_widget_annotations
我尝试使用它的应用程序example_usage
。
我将必要的包添加到我的dev_dependencies
. 这是我的pubspec.yaml
:
name: example_usage
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
animated_widget_generator:
path: ../animated_widget_generator
animated_widget_annotations:
path: ../animated_widget_annotations
build_runner: ^2.0.4
flutter:
uses-material-design: true
但是当我尝试在手机上运行该应用程序时,它给了我以下错误:
Launching lib\main.dart on ONEPLUS A6003 in debug mode...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
E/flutter (17052): [ERROR:flutter/shell/common/shell.cc(242)] Dart Error: error: import of dart:mirrors is not supported in the current Dart runtime
E/flutter (17052): [ERROR:flutter/runtime/dart_isolate.cc(169)] Could not prepare isolate.
E/flutter (17052): [ERROR:flutter/runtime/runtime_controller.cc(401)] Could not create root isolate.
E/flutter (17052): [ERROR:flutter/shell/common/shell.cc(571)] Could not launch engine with configuration.
Exited (1)
Stack Overflow 上还有其他关于这个错误的问题,但它们总是关于一些第三方包,而不是关于自定义源生成包,而且这些问题的任何答案似乎都与我无关
编辑:pubspec.yaml
对于animated_widget_generator
和animated_widget_annotations
:
name: animated_widget_annotations
description: A new Flutter package project.
version: 0.0.1
author:
homepage:
environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0"
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
name: animated_widget_generator
description: A new Flutter package project.
version: 0.0.1
author:
homepage:
environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0"
dependencies:
flutter:
sdk: flutter
path: ^1.8.0
source_gen: ^1.0.2
json_serializable: ^4.1.3
animated_widget_annotations:
path: ../animated_widget_annotations
dev_dependencies:
flutter_test:
sdk: flutter
pedantic: ^1.11.0
build_runner: ^2.0.4
flutter: