将 Flutter 更新至 v3.13.0 和 Dart v3.1.0 后(截至 2023 年 8 月 23 日稳定频道)
我的代码生成已损坏。
它在 v3.10.6 和 Dart v3.0.7 版本上运行得非常好。
这是我的
flutter doctor
输出
[✓] Flutter (Channel stable, 3.13.0, on macOS 13.4.1 22F82 darwin-arm64, locale en-ES)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.81.1)
[✓] Connected device (2 available)
[✓] Network resources
• No issues found!
我正在使用 Injectable 来生成我的工厂注册。
但是我遇到了
InvalidType is not a class element
错误
尝试从
auto_route
包注册外部模块 AppRouter 时似乎会抛出此错误。
这是外部模块的代码。相当简单明了
@module
abstract class AppRouterModule {
@singleton
AppRouter get appRouter => AppRouter();
}
我尝试过在不同的
build_runner
版本之间切换,但没有任何效果
有人遇到过这个问题吗?
可能不相关,但我遇到了类似的问题,并且对我的课程的引用之一的大小写不正确,即
import 'package:my_app/domain/models/responses/Region_response.dart';
而不是
import 'package:my_app/domain/models/responses/region_response.dart';
一旦我更正了引用的大小写,我的代码生成就很好,并且没有生成任何无效类型生成的代码。