当使用dart迁移后尝试在chrome或macos上运行我的应用程序时,我在控制台中得到以下错误:
Downloading Web SDK... 2,674ms
Launching lib/web/main.dev.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
../../../.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.1/lib/custom_style.dart:38:7: Error: Type 'ui.TextLeadingDistribution' not found.
ui.TextLeadingDistribution? leadingDistribution,
^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.1/lib/custom_style.dart:98:7: Error: Type 'ui.TextLeadingDistribution' not found.
ui.TextLeadingDistribution? leadingDistribution,
^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.1/lib/custom_style.dart:219:3: Error: Type 'ui.TextLeadingDistribution' not found.
ui.TextLeadingDistribution? get leadingDistribution =>
在Android/iPhone模拟器上运行良好。
我尝试了以下操作,但都无效:
- 扑动2.0.6(稳定)
- 扑动2.5.3(稳定)
- 扑动医生显示没有问题
- flutter clean, flutter pub cache repair, flutter pub get
- 重启VSCode
实际上,问题来自于依赖项styled_text。
我只从repo复制了我们需要的文件,这就解决了问题。