0

i have been trying to build this flutter project but i get this error every time. My flutter version is 3.3.9 image for the error

                             ^^^^^^^^^^
lib/screens/product_details.dart:652:32: Error: The method 'FlatButton' isn't defined for the class '_ProductDetailsState'.
 - '_ProductDetailsState' is from 'package:active_ecommerce_flutter/screens/product_details.dart' ('lib/screens/product_details.dart').
Try correcting the name to the name of an existing method, or defining a method named 'FlatButton'.
                        child: FlatButton(
                               ^^^^^^^^^^
lib/screens/product_details.dart:677:32: Error: The method 'FlatButton' isn't defined for the class '_ProductDetailsState'.
 - '_ProductDetailsState' is from 'package:active_ecommerce_flutter/screens/product_details.dart' ('lib/screens/product_details.dart').
Try correcting the name to the name of an existing method, or defining a method named 'FlatButton'.
                        child: FlatButton(
                               ^^^^^^^^^^
lib/screens/product_details.dart:2137:26: Error: The method 'FlatButton' isn't defined for the class '_ProductDetailsState'.
 - '_ProductDetailsState' is from 'package:active_ecommerce_flutter/screens/product_details.dart' ('lib/screens/product_details.dart').
Try correcting the name to the name of an existing method, or defining a method named 'FlatButton'.
                  return FlatButton(
                         ^^^^^^^^^^
lib/screens/chat.dart:417:16: Error: The method 'FlatButton' isn't defined for the class '_ChatState'.
 - '_ChatState' is from 'package:active_ecommerce_flutter/screens/chat.dart' ('lib/screens/chat.dart').
Try correcting the name to the name of an existing method, or defining a method named 'FlatButton'.
        child: FlatButton(
               ^^^^^^^^^^

please help me fix this im still new to flutter

i tried to downgrade my flutter version but still not possible

  • `FlatButton` is deprecated already you should change your button into other – Stanly Dec 13 '22 at 09:31
  • Does this answer your question? [Flutter FlatButton is deprecated - alternative solution with width and height](https://stackoverflow.com/questions/66805535/flutter-flatbutton-is-deprecated-alternative-solution-with-width-and-height) – Stanly Dec 13 '22 at 09:32

3 Answers3

0

Click on the link thrown in the exception it will navigate to the class where it is throwing an error search for FlatButton and replace it with ElevatedButton, because flatButton is deprecated

code example:

ElevatedButton(
  style: ElevatedButton.styleFrom(
    primary: Colors.red,
    padding: EdgeInsets.all(10),
  ),
  child: Text("Saved"),
  onPressed: () {
    // write your code here
  },
)
Ahmad Raza
  • 758
  • 7
  • 26
  • unfortunatelly i replace with ElevatedButton but still getting more error ../../../../development/flutter/packages/flutter/lib/src/material/elevated_button.dart:65:9: Context: Found this candidate, but the arguments don't match. const ElevatedButton({ ^^^^^^^^^^^^^^ – micky ngailo Dec 13 '22 at 10:00
  • can you please share code? – Ahmad Raza Dec 13 '22 at 10:06
0

Try using other buttons Like elevated button as flat button has been deprecated.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 16 '22 at 14:14
0

image for the code the flatbutton was used in many different places and it has its causing alot of erros in all places of code after upgrading my flutter project to 3.3.9 from 3.0.9 and i cant downgrade my flutter any more plz suggest me solution

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 16 '22 at 14:13