Reputation: 159
im getting these errors and dont know how to fix them.
../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(
^^^^^^^^^^
Upvotes: 15
Views: 32386
Reputation: 397
If you're on the latest version of Flutter, Flatbutton
is deprecated, use TextButton
instead. You can see the documentation here
Upvotes: 30
Reputation: 456
As seen from Flutter Documentation:
Old Widgets have been removed, Now you have to use the new widget along with the new theme. Here is a quick guide on how to use them.
Upvotes: 2
Reputation: 613
FlatButton is deprecated and totally removed from flutter after flutter 2.1.0 Use TextButton instead of FlatButton as follows:
TextButton(
style: TextButton.styleFrom(
foregroundColor: Colors.white,
padding: const EdgeInsets.all(16.0),
textStyle: const TextStyle(fontSize: 20),
),
onPressed: () {},
child: const Text('Gradient'),
),
Upvotes: 6
Reputation: 1
You just have to change the velocity_x:old version to new version. For Eg: in pubspec.yaml dependencies: velocity_x:^1.4.1 change it to ^3.2.1
Upvotes: 0
Reputation: 801
**Old Widget change to New Widget
FlatButton => TextButton
RaisedButton => ElevatedButton
OutlineButton => OutlinedButton**
for more details... https://docs.flutter.dev/release/breaking-changes/buttons#context
Upvotes: 18
Reputation: 41
Check the last package you added in pubspec.yaml and delete it and see if no error occurs then the error is because the package
Upvotes: 0