【问题标题】:Error: Method not found: 'ButtonTheme.bar'错误:找不到方法:'ButtonTheme.bar'
【发布时间】:2021-05-07 16:19:17
【问题描述】:

我正在开发颤振应用程序。运行应用程序时,出现错误 Method not found: 'ButtonTheme.bar'。 我尝试清理项目。但仍然存在同样的错误

/C:/Users/RdpUser/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/date_range_picker-1.0.6/lib/date_range_picker.dart:1152:44: Error: Method not found: 'ButtonTheme.bar'.
    final Widget actions = new ButtonTheme.bar(
                                           ^^^
Failed to compile application.

【问题讨论】:

  • 你可能需要升级你的flutter版本,并确定是最新版本的包date_range_picker,你能确认一下吗?

标签: flutter dart


【解决方案1】:

点击错误链接进入 my_alert_dialog.dart 并将 ButtonTheme.bar 更改为 ButtonBarTheme 像这个:

改为:

成功了!

【讨论】:

  • 感谢您的视觉帮助,但已经讨论了答案。请不要尝试以不同的形式重复回答
  • 我收到“错误:找不到方法:'ButtonBarTheme.bar'。”
【解决方案2】:

@pepe-calero 提到的临时解决方案如下所示:

在您的pubspec.yaml 中添加以下部分

dependency_overrides:
  date_range_picker:
    git:
      url: https://github.com/LempereurBenjamin/date_range_picker

【讨论】:

    【解决方案3】:

    使用这个,

    Deprecated. Please use ButtonBarTheme instead which offers more flexibility to configure ButtonBar widgets.
    
    This feature was deprecated after v1.9.1.
    
    

    因为ButtonTheme.bar 已被弃用。

    供参考,https://api.flutter.dev/flutter/material/ButtonTheme/ButtonTheme.bar.html

    【讨论】:

      【解决方案4】:

      我刚刚更新了颤振,我也不断收到这个错误。我同意@PatelFab,不推荐使用 ButtonTheme.bar。如果您在代码中“直接”使用 ButtonTheme.bar,只需将其更改为 ButtonBarTheme

      另一种解决方案是使用flutter showDateRangePicker function

      我有没有“直接”使用 ButtonTheme.bar 的问题,但是我依赖的另一个包使用它:flutter_form_builder。如果您使用flutter_form_builderthe issue has already been posted in github,我敢打赌他们正在努力。

      解决后我会更新。

      【讨论】:

        猜你喜欢
        • 2021-06-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-23
        • 2014-08-24
        相关资源
        最近更新 更多