Flutter提供商状态管理

时间:2020-04-16 13:21:35

标签: flutter flutter-state

enter image description here

var cart = Provider.of(context);

容器(宽度:120,子代:文本(cart.items [index] .name,样式:TextStyle(fontSize:14),)), SizedBox(width:10),

                    Container(width:60,child: Text(cart.items[index].Price.toString(),style: TextStyle(fontSize:14))),

                    SizedBox(width: 20),

                    Container(width:70,child: Text('${cart.ListOfQuantity[index]}',style: TextStyle(fontSize: 14))),

                    SizedBox(width: 20),

                    Container(width:70,child: Text((cart.ListOfQuantity[index]*cart.items[index].Price).toString(),style: TextStyle(fontSize: 14))),

Text(“ Total:” +'$ {cart.Total}'

我正在使用提供商状态管理技术

在此代码中,每当(单击添加按钮)AddItem函数被触发时,它都会更新小计和总计变量,该变量进一步用于构建/更新小部件 现在的问题是,每当单击“添加按钮”时,变量Subtotal和Total的值都会正确更新,但是在构建后,GUI上仅反映了Total value更改,GUI上没有反映Subtotal值更改

0 个答案:

没有答案