|
|
|
@ -11,7 +11,7 @@ class ShopCar extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
final List<ProductListBean> productLists; |
|
|
|
|
final Function(String id) queryMiNiDetail; |
|
|
|
|
final Function(int allCount, double allPrice) fc; |
|
|
|
|
final Function(ProductListBean productListBeans) fc; |
|
|
|
|
|
|
|
|
|
ShopCar( |
|
|
|
|
this.productLists, |
|
|
|
@ -27,12 +27,11 @@ class ShopCar extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _ShopCar extends State<ShopCar> { |
|
|
|
|
|
|
|
|
|
int allCount; |
|
|
|
|
double allPrice; |
|
|
|
|
|
|
|
|
|
int allCount = 0; |
|
|
|
|
double allPrice = 0; |
|
|
|
|
|
|
|
|
|
ProductListBean productListBeans; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
@ -59,8 +58,7 @@ class _ShopCar extends State<ShopCar> {
|
|
|
|
|
} |
|
|
|
|
widget.productLists.forEach((element) { |
|
|
|
|
allCount += element.buyNum; |
|
|
|
|
allPrice += double.parse(element.price) * |
|
|
|
|
element.buyNum; |
|
|
|
|
allPrice += double.parse(element.price) * element.buyNum; |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -125,8 +123,7 @@ class _ShopCar extends State<ShopCar> {
|
|
|
|
|
), |
|
|
|
|
child: ListView.builder( |
|
|
|
|
itemCount: widget.productLists == null |
|
|
|
|
? 0 |
|
|
|
|
: widget.productLists.length, |
|
|
|
|
? 0 : widget.productLists.length, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return GestureDetector( |
|
|
|
@ -135,11 +132,10 @@ class _ShopCar extends State<ShopCar> {
|
|
|
|
|
widget.productLists, |
|
|
|
|
position, |
|
|
|
|
widget.queryMiNiDetail, |
|
|
|
|
(int allCount, double allPrice){ |
|
|
|
|
widget.fc(allCount, allPrice); |
|
|
|
|
(ProductListBean productListBeans){ |
|
|
|
|
widget.fc(productListBeans); |
|
|
|
|
setState(() { |
|
|
|
|
this.allCount = allCount; |
|
|
|
|
this.allPrice = allPrice; |
|
|
|
|
this.productListBeans = productListBeans; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|