如何解决Flutter中的“FwfhTextStyle”错误?

20

由于这个错误,我的应用程序无法构建,我无法理解这个错误。 我尝试了'flutter upgrade'和'flutter get',但没有什么帮助。

Launching lib/main.dart on SM A127F in debug mode...
Running Gradle task 'assembleDebug'...
../../flutter/.pub-cache/hosted/pub.dartlang.org/fwfh_text_style-2.7.3+2/lib/fwfh_text_style.dart:11:7: Error: The non-abstract class 'FwfhTextStyle' is missing implementations for these members:
 - TextStyle.fontVariations
Try to either
 - provide an implementation,
 - inherit an implementation from a superclass or mixin,
 - mark the class as abstract, or
 - provide a 'noSuchMethod' implementation.

class FwfhTextStyle extends _TextStyleProxy {
      ^^^^^^^^^^^^^
../../flutter/packages/flutter/lib/src/painting/text_style.dart:789:33: Context: 'TextStyle.fontVariations' is defined here.
  final List<ui.FontVariation>? fontVariations;
                                ^^^^^^^^^^^^^^ 


FAILURE: Build failed with an exception.

* Where:
Script '/home/vrs/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1159

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/home/vrs/flutter/bin/flutter'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 16s
Exception: Gradle task assembleDebug failed with exit code 1

6个回答

14

我升级到Flutter 3.3.0 后遇到了这个错误。

在做了一些搜索后,我通过运行项目中的软件包升级解决了它。

flutter pub upgrade 

然后

flutter clean 

flutter pub get

1
这个错误是由于一个名为“Better Player”的插件引起的。我已经将其移除。 - Vinayak Sutar

14
请尝试更新依赖项flutter pub upgrade fwfh_text_style以进行测试。

1
我认为这是关于final List<ui.FontVariation>? fontVariations;的定义问题。它可能被定义在最后一个索引位置,也可能根本没有定义。
为了避免错误,我会像这样做:List<ui.FontVariation> fontVariations = [];

1
如果还没有添加,请尝试在您的项目中添加fwfh_text_style这个插件。它对我很有效。

你的回答可以通过提供更多支持信息来改进。请编辑以添加进一步的细节,例如引用或文档,以便他人可以确认你的答案是正确的。您可以在帮助中心中找到有关如何编写良好答案的更多信息。 - mohammad mobasher

0

我尝试了flutter upgradeflutter clean,但对我没有用。

然后我运行了这个命令flutter pub outdated,它很有效。


0

我必须运行 rm -rf ~/.pub-cache 然后运行 flutter pub get ‍♂️


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接