参数类型“Widget Function(BuildContext, Object?)”无法分配给参数类型 'Widget Function(BuildContext,dynamic,VxStatus?

发布于 2025-01-11 22:27:37 字数 1394 浏览 2 评论 0原文

[Issue 1 :)'. ][1]

参数类型“Widget Function(BuildContext,Object?)”无法分配给参数类型“Widget Function(BuildContext,dynamic,VxStatus?”

尝试使用 Vxbuilder 或 Vxconsumer 更新购物车总数,但会弹出此错误

class _CartTotal extends StatelessWidget {
  final CartModel _cart = (VxState.store as MyStore).cart;
  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 200,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: [
          VxBuilder(
            mutations: {RemoveMutation},
            //notifications: {},
            builder: (context, _ ){
            return "\$${_cart.totalPrice}"
              .text
              .xl5
              .color(context.theme.accentColor)
              .make();
          }, 
          );
          30.widthBox,
          TextButton(
                  onPressed: () {
                    ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                      content: "Buying not supported yet".text.center.make(),
                    ));
                  },
                  style: ButtonStyle(
                      backgroundColor:
                          MaterialStateProperty.all(context.theme.buttonColor)),
                  child: "Buy".text.xl3.color(Colors.black).make())
              .w32(context),
        ],
      ),
    );
  }
}
'''
[Issue 1 :)'. ][1]

The argument type 'Widget Function(BuildContext, Object?)' can't be assigned to the parameter type 'Widget Function(BuildContext, dynamic, VxStatus?

Trying to update the cart total using Vxbuilder or Vxconsumer but this errors pops in

class _CartTotal extends StatelessWidget {
  final CartModel _cart = (VxState.store as MyStore).cart;
  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 200,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: [
          VxBuilder(
            mutations: {RemoveMutation},
            //notifications: {},
            builder: (context, _ ){
            return "\${_cart.totalPrice}"
              .text
              .xl5
              .color(context.theme.accentColor)
              .make();
          }, 
          );
          30.widthBox,
          TextButton(
                  onPressed: () {
                    ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                      content: "Buying not supported yet".text.center.make(),
                    ));
                  },
                  style: ButtonStyle(
                      backgroundColor:
                          MaterialStateProperty.all(context.theme.buttonColor)),
                  child: "Buy".text.xl3.color(Colors.black).make())
              .w32(context),
        ],
      ),
    );
  }
}
'''

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蘑菇王子 2025-01-18 22:27:37

这一行:

 builder: (context, _ ){

您正在声明一个函数,该函数需要 3 个参数,但您只传递 2 个参数,添加第三个参数:

 builder: (context, _, __) {

This line:

 builder: (context, _ ){

You are declaring a function, this function takes 3 arguments, but you are only passing 2, add a third argument:

 builder: (context, _, __) {
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文