Android Studio 错误:没有为类“PlatformButton "定义方法”FlatButton"

gzjq41n4  于 2022-11-16  发布在  Android
关注(0)|答案(3)|浏览(174)

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

../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(
             ^^^^^^^^^^
6yoyoihd

6yoyoihd1#

如果您使用的是Flutter的最新版本,则不建议使用Flatbutton,请改用TextButton。

x6h2sr28

x6h2sr282#

**Old Widget        change to    New Widget      
FlatButton   =>      TextButton      
RaisedButton =>      ElevatedButton  
OutlineButton =>    OutlinedButton**

有关详细信息... https://docs.flutter.dev/release/breaking-changes/buttons#context

9fkzdhlc

9fkzdhlc3#

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

相关问题