【问题标题】:Error: The method 'FlatButton' isn't defined for the class 'PlatformButton'错误:没有为类 \'PlatformButton\' 定义方法 \'FlatButton\'
【发布时间】:2022-10-20 18:07:18
【问题描述】:

我收到这些错误,不知道如何修复它们。

../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_platform_widgets-1.20.0/lib/src/platform_button.dart:269:14: Error: The method 'FlatButton' isn't defined for the class 'PlatformButton'.
 - 'PlatformButton' is from 'package:flutter_platform_widgets/src/platform_button.dart' ('../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_platform_widgets-1.20.0/lib/src/platform_button.dart').
Try correcting the name to the name of an existing method, or defining a method named 'FlatButton'.
      return FlatButton(
             ^^^^^^^^^^

../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_platform_widgets-1.20.0/lib/src/platform_button.dart:302:12: Error: The method 'RaisedButton' isn't defined for the class 'PlatformButton'.
 - 'PlatformButton' is from 'package:flutter_platform_widgets/src/platform_button.dart' ('../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_platform_widgets-1.20.0/lib/src/platform_button.dart').
Try correcting the name to the name of an existing method, or defining a method named 'RaisedButton'.
    return RaisedButton(
           ^^^^^^^^^^^^

../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_platform_widgets-1.20.0/lib/src/platform_dialog_action.dart:171:14: Error: The method 'FlatButton' isn't defined for the class 'PlatformDialogAction'.
 - 'PlatformDialogAction' is from 'package:flutter_platform_widgets/src/platform_dialog_action.dart' ('../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_platform_widgets-1.20.0/lib/src/platform_dialog_action.dart').
Try correcting the name to the name of an existing method, or defining a method named 'FlatButton'.
      return FlatButton(
             ^^^^^^^^^^

【问题讨论】:

  • 请提供足够的代码,以便其他人可以更好地理解或重现该问题。

标签: ios flutter android-studio dart


【解决方案1】:

如果您使用的是最新版本的 Flutter,不推荐使用 Flatbutton,请改用 TextButton。

【讨论】:

  • 这个错误没有指出,我们如何知道平面按钮在项目中的使用位置?
【解决方案2】:

检查您在 pubspec.yaml 中添加的最后一个包并将其删除,看看是否没有发生错误,那么错误是因为该包

【讨论】:

    猜你喜欢
    • 2021-02-24
    • 2021-07-26
    • 2021-04-15
    • 2020-05-21
    • 2019-05-10
    • 1970-01-01
    • 2022-09-28
    • 1970-01-01
    • 2020-02-15
    相关资源
    最近更新 更多