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
CodePudding user response:
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
},
)
CodePudding user response:
Try using other buttons Like elevated button as flat button has been deprecated.
CodePudding user response:
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