【问题标题】:Flutter: A value of type 'ListTileThemeData' can't be assigned to a variable of type 'ListTileTheme'Flutter:无法将“ListTileThemeData”类型的值分配给“ListTileTheme”类型的变量
【发布时间】:2022-01-15 23:07:19
【问题描述】:

我发布这个问题是为了帮助未来的读者。升级到Flutter 2.8 后,我在尝试运行我的应用程序时突然收到此错误:

Flutter: A value of type 'ListTileThemeData' can't be assigned to a variable of type 'ListTileTheme'.

我是如何解决这个问题的?

【问题讨论】:

  • 我看到超过 200 人在 7 天内查看了这个问题。如果我帮助您,我们将不胜感激。

标签: flutter dart mobile flutter2.0


【解决方案1】:

原来这个错误是由我使用的一个流行库 (settings_ui) 引起的,它不适用于这个版本的 Flutter (settings_ui: ^1.0.0)。


对于未来的读者:使用此软件包的更高版本。目前github 上有一个未解决的问题可以解决这个问题。

2022 年更新:settings_ui 上的开发人员似乎已经离开,不再合并 PR 社区已将此项目分叉到:https://pub.dev/packages/flutter_settings_ui,此处更新已正确合并,并已在1.0.1版


对于现在面临此问题的人:

作为猴子补丁,您可以按照 GitHub 问题中的步骤并在本地编辑包文件:

cupertino_settings_item.dartfinal ListTileTheme tileTheme = ListTileTheme.of(context); 更改为final tileTheme = ListTileTheme.of(context);

并将_iconColor(ThemeData theme, ListTileTheme tileTheme) 更改为_iconColor(ThemeData theme, ListTileThemeData tileTheme)

【讨论】:

    猜你喜欢
    • 2022-01-03
    • 1970-01-01
    • 2022-11-23
    • 1970-01-01
    • 1970-01-01
    • 2021-08-24
    • 2022-11-01
    • 2020-02-01
    • 2020-01-21
    相关资源
    最近更新 更多