skip to Main Content

Please i don’t explicitly use RaiseButton or FlatButton in my code. But i get this error

../../snap/flutter/common/flutter/.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' ('../../snap/flutter/common/flutter/.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(
             ^^^^^^^^^^
../../snap/flutter/common/flutter/.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' ('../../snap/flutter/common/flutter/.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(
           ^^^^^^^^^^^^

Thank for help

I tried this solution who did not work for me.

4

Answers


  1. flutter_platform_widgets used those deprecated widgets. If you update it to 2.0.0 problem will be fixed

    flutter_platform_widgets/changelog

    Login or Signup to reply.
  2. With Flutter > 2.0, RaisedButton widget is deprecated and replaced by ElevatedButton widget. One example usage of ElevatedButton is mentioned here

    For more info, check the official docs: https://api.flutter.dev/flutter/material/RaisedButton-class.html

    Login or Signup to reply.
  3. You are using older version of flutter_platform_widgets and in that version, package use RaisedButton and FlatButton which are deprecated, so try updated your package to newer version like: flutter_platform_widgets: ^2.0.0 .

    If you not used flutter_platform_widgets directly, you need to search in all your packages and check which package use flutter_platform_widgets and try to updated that.

    Login or Signup to reply.
  4. You can no longer use RaisedButton or FlatButton in the latest versions they are deprecated. Use ElevatedButton instead.

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