1 Star 0 Fork 357

北京驰久科技有限公司/linjiashop-flutter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cart_bottom.dart 3.37 KB
一键复制 编辑 原始数据 按行查看 历史
import 'package:flutter/material.dart';
import 'package:flutter_app/models/cart_goods_query_entity.dart';
import 'package:flutter_app/routes/routes.dart';
import 'package:flutter_app/utils/app_size.dart';
import 'receiver/event_bus.dart';
class CartBottom extends StatelessWidget {
List<GoodsModel> list;
bool isAllCheck;
CartBottom(this.list,this.isAllCheck);
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.all(5.0),
height:AppSize.height(140.0) ,
color: Colors.white,
width:AppSize.width(1080),
child: Row(
children: <Widget>[
selectAllBtn(),
allPriceArea(),
goButton(context)
],
)
);
}
//全选按钮
Widget selectAllBtn(){
return Container(
child: Row(
children: <Widget>[
Checkbox(
value: isAllCheck,
activeColor: Colors.pink,
onChanged: (bool val){
list.forEach((el){
el.isCheck= val;
});
eventBus.fire(new GoodsNumInEvent("All"));
},
),
Text('全选')
],
),
);
}
double allPrice=0;
// 合计区域
Widget allPriceArea(){
list.forEach((el){
if(el.isCheck){
allPrice=allPrice+ el.countNum*(el.price/100);
}
});
return Container(
alignment: Alignment.center,
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Container(
alignment: Alignment.centerRight,
width: AppSize.width(220),
height:AppSize.height(140) ,
child: Text(
'合计:',
style:TextStyle(
fontSize: AppSize.sp(36)
)
),
),
Container(
alignment: Alignment.centerLeft,
width: AppSize.width(240),
child: Text(
'¥${allPrice.toStringAsFixed(2)}',
style:TextStyle(
fontSize:AppSize.sp(36),
color: Colors.red,
)
),
)
],
),
],
),
);
}
//结算按钮
Widget goButton(BuildContext context){
int allGoodsCount=0;
int isAll=0;
list.forEach((el){
if(el.isCheck){
isAll++;
allGoodsCount=allGoodsCount+ el.countNum;
}
});
if(isAll==list.length){
eventBus.fire(new GoodsNumInEvent("All"));
}
return Container(
width:AppSize.width(360),
padding: EdgeInsets.only(left: 30),
child:InkWell(
onTap: (){
Map<String, String> p={"orderSn":"","totalPrice":allPrice.toStringAsFixed(2)};
Routes.instance.navigateToParams(context,Routes.pay_page,params: p);
},
child: Container(
padding: EdgeInsets.all(10.0),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(3.0)
),
child: Text(
'结算(${allGoodsCount})',
style: TextStyle(
color: Colors.white
),
),
),
) ,
);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Dart
1
https://gitee.com/BeiJingchi-j/linjiashop-flutter.git
git@gitee.com:BeiJingchi-j/linjiashop-flutter.git
BeiJingchi-j
linjiashop-flutter
linjiashop-flutter
master

搜索帮助

371d5123 14472233 46e8bd33 14472233