我一直试图建立这个Flutter项目,但我得到这个错误的每一次,我的Flutter版本是3.3.9

wko9yo5t  于 2022-12-14  发布在  Flutter
关注(0)|答案(3)|浏览(379)

我一直试图建立这个Flutter项目,但我得到这个错误的每一次。我的Flutter版本是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(
               ^^^^^^^^^^

请帮我解决这个我还是新的Flutter
我试图降级我的Flutter版本,但仍然不可能

6uxekuva

6uxekuva1#

单击异常中抛出的链接,它将导航到抛出错误的类,搜索FlatButton并将其替换为ElevatedButton,因为flatButton已弃用
代码示例:

ElevatedButton(
  style: ElevatedButton.styleFrom(
    primary: Colors.red,
    padding: EdgeInsets.all(10),
  ),
  child: Text("Saved"),
  onPressed: () {
    // write your code here
  },
)
lsmepo6l

lsmepo6l2#

尝试使用其他按钮像升高的按钮作为平面按钮已被弃用。

b1uwtaje

b1uwtaje3#

image for the code的flatbutton是用在许多不同的地方,它有它的所有地方的代码造成了很多错误后,我的flutter项目升级到3. 3. 9从3. 0. 9,我不能降级我的flutter任何更多的plz建议我的解决方案

相关问题