skip to Main Content

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(
             ^^^^^^^^^^

6

Answers


  1. If you’re on the latest version of Flutter, Flatbutton is deprecated, use TextButton instead.

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
  3. **Old Widget        change to    New Widget      
    FlatButton   =>      TextButton      
    RaisedButton =>      ElevatedButton  
    OutlineButton =>    OutlinedButton**
    

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

    Login or Signup to reply.
  4. 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

    Login or Signup to reply.
  5. 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'),
                ),
    
    Login or Signup to reply.
  6. As seen from Flutter Documentation:
    enter image description here

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search