Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: The method 'FlatButton' isn't defined for the class 'PlatformButton'

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(
             ^^^^^^^^^^
like image 585
Cristian Avatar asked Jan 19 '26 19:01

Cristian


2 Answers

If you're on the latest version of Flutter, Flatbutton is deprecated, use TextButton instead. You can see the documentation here

like image 143
Pawandeep Singh Avatar answered Jan 22 '26 09:01

Pawandeep Singh


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

for more details... https://docs.flutter.dev/release/breaking-changes/buttons#context

like image 34
Rasathurai Karan Avatar answered Jan 22 '26 10:01

Rasathurai Karan