![](/img/trans.png)
[英]ib/main.dart:49:24: Error: The operator '[]' isn't defined for the class 'Set<Map<String, Object>>'
[英]Error: The method 'FlatButton' isn't defined for the class 'PlatformButton'
我收到這些錯誤並且不知道如何修復它們。
../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(
^^^^^^^^^^
**Old Widget change to New Widget
FlatButton => TextButton
RaisedButton => ElevatedButton
OutlineButton => OutlinedButton**
有關詳細信息... https://docs.flutter.dev/release/breaking-changes/buttons#context
舊的小部件已被刪除,現在您必須使用新的小部件和新的主題。 這是有關如何使用它們的快速指南。
如果您使用的是最新版本的 Flutter,不推薦使用 Flatbutton,請改用 TextButton。
檢查你在pubspec.yaml中添加的最后一個package並刪除它,看看是否沒有錯誤發生那么錯誤是因為package
您只需將 velocity_x:old 版本更改為新版本。 例如:在 pubspec.yaml 依賴項中:velocity_x:^1.4.1 將其更改為 ^3.2.1
new flutter SDK中沒有FlatButton ,使用TextButton代替FlatButton如下:
TextButton(
style: TextButton.styleFrom(
foregroundColor: Colors.white,
padding: const EdgeInsets.all(16.0),
textStyle: const TextStyle(fontSize: 20),
),
onPressed: () {},
child: const Text('Gradient'),
),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.