import 'dart:async'; // import 'dart:html'; import 'dart:io'; import 'package:barcode_scan/barcode_scan.dart'; import 'package:flustars/flustars.dart' as FlutterStars; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; // import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:image_picker/image_picker.dart'; import 'package:liftmanager/common/user_db.dart'; import 'package:liftmanager/internal/account/model/user_info_entity.dart'; import 'package:liftmanager/internal/account/provider/user_provider.dart'; import 'package:liftmanager/internal/wode/page/reward_record_list.dart'; import 'package:liftmanager/internal/wode/wode_router.dart'; import 'package:liftmanager/net/api_service.dart'; import 'package:liftmanager/res/colors.dart'; import 'package:liftmanager/routers/fluro_navigator.dart'; import 'package:liftmanager/utils/fast_notification.dart'; import 'package:liftmanager/utils/toast.dart'; import 'package:liftmanager/utils/utils.dart'; import 'package:liftmanager/widgets/load_image.dart'; import 'package:provider/provider.dart'; class WodePage extends StatefulWidget { //1用户 2专家 String type = "2"; @override State createState() { return WodePageState(); } } class WodePageState extends State with AutomaticKeepAliveClientMixin { UserProvider provider = UserProvider(); ///自己造数据 ///vip // bool _isVip = true; // ///是否是专家 bool _iszz = FlutterStars.SpUtil.getInt("expertFlag") == 1; @override void initState() { super.initState(); upDataUserLogin(); getUserInfo(); getCoupon(); getExpertOrderCont(); FastNotification.addListener("initUserMoney", (initThisUserMoney) { if (mounted) { getCoupon(); setState(() {}); } }); FastNotification.addListener("initUserInfomation", (initThisUserInfomation) { if (mounted) { getUserInfo(); setState(() {}); } }); } String indexNow; final _cancelController = TextEditingController(text: "取消"); Map detailOj = { "couponNum": 0, "balance": 0.0, "hongBaoNum": 0, "memberDays": "", }; int isVip = 1; ///获取用户信息 void getUserInfo() { ApiService(context: context).userInfo( onSuccess: (data) { setUser(data); // print(data.showWhichName); indexNow = data.showWhichName.toString(); }, onError: (code, msg) {}, ); } //更新用户信息 Future upDataUserLogin() async { await NewApiService().upDataUserLogin(onSuccess: (res) { User().setCurrentUser(res, type: 'upDataAppMenus'); _iszz = FlutterStars.SpUtil.getInt("expertFlag") == 1; String initThisUserMoney = randomInt(1111, 9999).toString() + DateTime.now().millisecondsSinceEpoch.toString(); FastNotification.push("initUserMoney", initThisUserMoney); String initThisUserInfomation = randomInt(1111, 9999).toString() + DateTime.now().millisecondsSinceEpoch.toString(); FastNotification.push("initUserInfomation", initThisUserInfomation); // setState(() {}); }, onError: (code, msg) { toasts(msg); }); } Map expertorderOj = { "totalMoney": 0, "askNum": 0, "outNum": 0, "dealingNum": 0 }; ///获取专家订单信息 void getExpertOrderCont() { NewApiService().getExpertOrderCont( onSuccess: (data) { expertorderOj = data; print(data); setState(() {}); // setUser(data); // print(data.showWhichName); // indexNow = data.showWhichName.toString(); }, onError: (code, msg) {}, ); } Future scan() async { try { // 此处为扫码结果,barcode为二维码的内容 String barcode = await BarcodeScanner.scan(); print(barcode); // http://lift.whlhcx.com/h5/index.html?page=/wode/vip&id=1288674418578472962 // return; // print('扫码结果: ' + jsonDecode(barcode)["url"]); Uri u = Uri.parse(barcode); String id = u.queryParameters['id']; print('扫码结果: ' + id); // print('扫码结果: ' + jsonDecode(barcode)["userId"].toString()); NewApiService().getUserRebates(id, onSuccess: (res) { toastsF( context, "你已成功接受${res != null ? res.toString() : ''}的邀请,立即成为会员!", timeInSecForIos: 3); // toasts("您已成为${res!=null?res.toString():''}的下级用户"); NavigatorUtils.push(context, "${WodeRouter.vip}?id="); }, onError: (code, msg) { toasts(msg); }); } on PlatformException catch (e) { if (e.code == BarcodeScanner.CameraAccessDenied) { // 未授予APP相机权限 print('未授予APP相机权限'); } else { // 扫码错误 print('扫码错误: $e'); } } on FormatException { // 进入扫码页面后未扫码就返回 print('进入扫码页面后未扫码就返回'); } catch (e) { // 扫码错误 print('扫码错误: $e'); } } // Future scan() async { // String barcodeScanRes; // // Platform messages may fail, so we use a try/catch PlatformException. // try { // barcodeScanRes = await FlutterBarcodeScanner.scanBarcode( // "#ff6666", "取消", true, ScanMode.BARCODE); // print(123456); // print(barcodeScanRes); // Uri u = Uri.parse(barcodeScanRes); // String id = u.queryParameters['id']; // print("123456--" + id); // NewApiService().getUserRebates(id, // onSuccess: (res) { // toastsF(context,"你已成功接受${res!=null?res.toString():''}的邀请,立即成为会员!",timeInSecForIos:3); // // toasts("您已成为${res!=null?res.toString():''}的下级用户"); // NavigatorUtils.push(context, "${WodeRouter.vip}?id="); // }, onError: (code, msg) { // toasts(msg); // }); // } on PlatformException { // barcodeScanRes = 'Failed to get platform version.'; // } // // If the widget was removed from the tree while the asynchronous platform // // message was in flight, we want to discard the reply rather than calling // // setState to update our non-existent appearance. // if (!mounted) return; // } Future getCoupon() async { await NewApiService().getUserCoupons(onSuccess: (res) { if (res != null) { detailOj["couponNum"] = res["couponNum"]; detailOj["balance"] = res["balance"]; detailOj["hongBaoNum"] = res["hongBaoNum"]; detailOj["memberDays"] = res["memberDays"]; isVip = res["isVip"]; FlutterStars.SpUtil.putInt('isVip', isVip); setState(() {}); print(6666544); } }, onError: (code, msg) { toasts(msg); }); } void setUser(UserInfoEntity user) { provider.setUser(user); } ///选择图片 void selectPicker() { showDialog( context: context, builder: (BuildContext context) { return SimpleDialog( title: Text("修改头像"), children: ["拍照", '从手机相册选择'].map((String value) { print("$value"); return SimpleDialogOption( child: Text( "${value}", style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500), ), onPressed: () { _getImage(value == '拍照' ? 1 : 0); Navigator.of(context).pop(); }, ); }).toList(), ); }, ); } void _getImage(int key) async { try { var _imageFile = await ImagePicker.pickImage( source: key == 1 ? ImageSource.camera : ImageSource.gallery, maxWidth: 800, imageQuality: 95); if (_imageFile != null) { updateAvatar(_imageFile); setState(() {}); } } catch (e) { toasts("没有权限,无法打开相册!"); } } void updateAvatar(File imageFile) { List list = [imageFile]; ApiService(context: context).uploadMore(list, onSuccess: (imgs) { ApiService(context: context).modifyAvatar(imgs[0], onSuccess: (res) { if (res != null) { getUserInfo(); } }, onError: (code, msg) { toasts(msg); }); }); } void _updateUserInfo(value) { ApiService(context: context).modifyName(value, onSuccess: (res) { if (res != null) { getUserInfo(); } }, onError: (code, msg) { toasts(msg); }); } @override void dispose() { // provider.dispose(); super.dispose(); } static const OrderTypeList = [ { "title": "待付款", "img": "wode/order_1", }, { "title": "待确认", "img": "wode/order_3", }, { "title": "待评价", "img": "wode/order_2", }, { "title": "申诉", "img": "wode/order_4", }, ]; @override Widget build(BuildContext context) { return // Center(child:new Text("个人中心")); ChangeNotifierProvider( create: (_) => provider, child: Scaffold( body: Consumer( builder: (_, provider, __) { return Container( color: Colours.grey_app_bg, child: Column( children: [ _headWidget(), Expanded( child: RefreshIndicator( onRefresh: () async { setState(() { getUserInfo(); getCoupon(); getExpertOrderCont(); upDataUserLogin(); }); }, child: ListView( padding: EdgeInsets.only(top: 0), children: [ _iszz ? _myJieDan() : Container(), _myOrder(context), _applications(), ], ), ), ), ], )); }, ), ), ); } _headWidget() { MediaQueryData mq = MediaQuery.of(context); return ClipPath( clipper: BottomClipper(clipheight: 15), //路 child: Stack( children: [ Positioned( left: 0, right: -40, child: Container( // color: Colors.red, height: 225 + mq.padding.top, width: double.infinity, child: LoadAssetImage( "wode_head_bg", fit: BoxFit.cover, // key: const Key('add'), // color: Colors.white, ), ), ), Container( margin: EdgeInsets.only( right: ScreenUtil().setWidth(8), top: mq.padding.top), height: 210, child: Column( children: [ Container( height: 60, // color: Colors., child: Stack( children: [ Container( width: double.infinity, alignment: Alignment.center, child: Text( '个人中心', style: TextStyle( color: Colors.white, fontWeight: FontWeight.w400, fontSize: 16), ), ), Positioned( top: 0, right: -10, child: Container( height: 60, // alignment: Alignm, child: IconButton( onPressed: () { NavigatorUtils.push(context, "${WodeRouter.settingPage}?indexNow=$indexNow"); }, icon: LoadAssetImage( "icon_setting", key: const Key('add'), width: 24, height: 24, color: Colors.white, ), ), )) ], ), ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ GestureDetector( onTap: () { NavigatorUtils.push(context, WodeRouter.personalPage); }, child: Container( padding: EdgeInsets.only( left: 10, // top: ScreenUtil().setHeight(5), // bottom: ScreenUtil().setWidth(25), ), child: Row( children: [ Container( padding: EdgeInsets.only( right: 10, ), child: // CircleAvatar( // radius: 24, // backgroundColor: Colors.transparent, // backgroundImage: // ImageUtils.getImageProvider( // provider.user?.avatarUrl), // ), ClipRRect( borderRadius: BorderRadius.circular( ScreenUtil().setWidth(35)), child: Container( child: LoadNetworkImage( provider.user?.avatarUrl, // fit: BoxFit.fitWidth, width: ScreenUtil().setWidth(70), height: ScreenUtil().setWidth(70), ), ))), Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Container( child: Text( provider.user?.showWhichName == 1 ? (provider.user?.nickName ?? "") : (provider.user?.userName ?? ""), textAlign: TextAlign.left, style: TextStyle( fontSize: ScreenUtil().setSp(16), color: Color(0xffffffff), ), ), ), // img_vip_icon // provider.us LoadAssetImage( isVip == 2 ? 'img_vip_icon' : 'img_novip_icon', height: 17, width: 20, fit: BoxFit.fill, // alignment: Alignment.centerLeft, ), ], ), SizedBox(height: 3), Row( children: [ Stack( children: [ Container( child: LoadAssetImage( // image: AssetImage(i['img']), _iszz ? 'img_user_expert' : 'img_user_ordinary', height: 20, width: 65, fit: BoxFit.fill, // alignment: Alignment.centerLeft, ), ), Container( height: 20, // width: ScreenUtil()certificateStatus // .setWidth(65), alignment: Alignment.centerLeft, margin: EdgeInsets.only(left: 20), child: Text( _iszz ? '${provider.user?.userLevelName} Lv${FlutterStars.SpUtil.getInt("expertLevel")}' : '${provider.user?.userLevelName}', style: TextStyle( color: Colors.white, fontSize: 10), ), ) ], ), // GestureDetector( // onTap: () { // // print(provider.user.userLevel); // NavigatorUtils.push(context, // "${WodeRouter.vip}?id="); // }, // child: Container( // padding: EdgeInsets.only( // left: 6, // right: 6, // top: 2, // bottom: 2, // ), // decoration: BoxDecoration( // borderRadius: // BorderRadius.circular( // 10.0), // color: Colors.white, // ), // child: Row( // children: [ // Container( // child: LoadAssetImage( // // image: AssetImage(i['img']), // 'wode/zuan', // height: ScreenUtil() // .setWidth(11), // width: ScreenUtil() // .setWidth(12), // fit: BoxFit.cover, // // alignment: Alignment.centerLeft, // ), // ), // SizedBox(width: 3), // Text( // provider.user?.userLevelName != // null && // provider.user // ?.userLevelName != // '' // ? provider.user // ?.userLevelName // : "成为会员", // textAlign: // TextAlign.left, // style: TextStyle( // fontSize: // ScreenUtil() // .setSp(11), // color: Color( // 0xff0288FF), // ), // ), // ], // ), // ), // ), // SizedBox( // width: 10, // ), // Container( // child: Text( // detailOj["memberDays"] ?? // "", // textAlign: TextAlign.left, // style: TextStyle( // fontSize: ScreenUtil() // .setSp(14), // color: Color(0xffffffff), // ), // ), // ) ], ) ], ), ], ), ), ), InkWell( onTap: () { NavigatorUtils.push(context, WodeRouter.walletPage); }, child: Column( crossAxisAlignment: CrossAxisAlignment.end, // mainAxisAlignment: MainAxisAlignment.end, children: [ Container( // alignment: Alignment.centerRight, child: Text( detailOj["balance"] != null ? detailOj["balance"].toString() : "0.0", style: TextStyle( color: Colors.white, fontSize: ScreenUtil().setSp(18)), ), ), Row( children: [ Text( '账户余额', style: TextStyle( color: Colors.white, fontSize: ScreenUtil().setSp(12)), ), Icon( Icons.arrow_forward_ios, size: 10, color: Colors.white, ) ], ) ], ), ) ], ), ], ), ), Positioned( bottom: 5, left: 10, right: 10, child: InkWell( onTap: () { NavigatorUtils.push(context, "${WodeRouter.vip}?id="); }, child: Container( height: 45, child: LoadAssetImage( "img_vip_tip", fit: BoxFit.fill, // key: const Key('add'), // color: Colors.white, ), ), )) ], )); } _myJieDan() { // widget a = Row(children: [],); return TitleCard( title: '我的接单', rightText: '查看全部接单', onTapRight: () { NavigatorUtils.push( context, "${WodeRouter.orderPageMaster}?checkType=0"); }, body: Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, // crossAxisAlignment: CrossAxisAlignment.center // crossAxisAlignment: co, children: [ SizedBox( width: ScreenUtil().setWidth(5), ), Container( padding: EdgeInsets.only(top: 15), child: Column( // crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( expertorderOj['totalMoney'].toString(), style: TextStyle( color: Colours.dark_text_gray, fontSize: 17), ), SizedBox( height: 5, ), Text( '总收益', style: TextStyle( color: Colours.dark_text_gray, fontSize: 13), ), ], ), ), SizedBox( width: ScreenUtil().setWidth(30), ), Container( padding: EdgeInsets.only(top: 15), child: Column( // crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( expertorderOj['askNum'].toString(), style: TextStyle( color: Colours.dark_text_gray, fontSize: 17), ), SizedBox( height: 5, ), Text( '问诊单数', style: TextStyle( color: Colours.dark_text_gray, fontSize: 13), ), ], ), ), SizedBox( width: ScreenUtil().setWidth(30), ), Container( padding: EdgeInsets.only(top: 15), child: Column( // crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( expertorderOj['outNum'].toString(), style: TextStyle( color: Colours.dark_text_gray, fontSize: 17), ), SizedBox( height: 5, ), Text( '出诊单数', style: TextStyle( color: Colours.dark_text_gray, fontSize: 13), ), ], ), ), Container( margin: EdgeInsets.only(top: 15, left: 10), // color: Colors.red, height: 30, width: 5, child: LoadAssetImage( "icon_line", fit: BoxFit.cover, // key: const Key('add'), // color: Colors.white, ), ), // Icon(icon) SizedBox( height: 5, ), InkWell( onTap: () { NavigatorUtils.push( context, "${WodeRouter.orderPageMaster}?checkType=0"); }, child: Container( margin: EdgeInsets.only(top: 10), // height: 100, child: Stack( children: [ Column( // crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( height: 5, ), Icon( const IconData(0xe61f, fontFamily: "Iconfont"), ), SizedBox( height: 1, ), Text( '待处理', style: TextStyle( color: Colours.dark_text_gray, fontSize: 13), ), ], ), Positioned( top: 0, right: 0, child: Container( height: 16, width: 16, alignment: Alignment.center, decoration: BoxDecoration( //背景 color: Colors.white, //设置四周圆角 角度 borderRadius: BorderRadius.all(Radius.circular(10.0)), //设置四周边框 border: Border.all(width: 1, color: Colors.red), ), child: Text(expertorderOj['dealingNum'].toString(), style: TextStyle(fontSize: 9, color: Colors.red)), )), ], ), ), ), SizedBox( width: ScreenUtil().setWidth(5), ), ], ), )); } _myOrder(context) { List brandList(context) => OrderTypeList.asMap().keys.map( (item) { double width = MediaQuery.of(context).size.width; return Container( padding: EdgeInsets.only(top: 15), child: _iconItem( size: 30, title: OrderTypeList[item]["title"], icon: OrderTypeList[item]['img'], ontap: () { int nums = item + 1; String index = nums.toString(); NavigatorUtils.push( context, "${WodeRouter.orderPage}?checkType=$index"); }, ), ); // InkWell( // onTap: () { // int nums = item + 1; // String index = nums.toString(); // NavigatorUtils.push( // context, "${WodeRouter.orderPage}?checkType=$index"); // }, // child: Container( // padding: EdgeInsets.only(top: 15), // child: Column( // // crossAxisAlignment: CrossAxisAlignment.center, // children: [ // Container( // // height: 70, // // color: Colors.red, // child: LoadAssetImage( // // image: AssetImage(i['img']), // OrderTypeList[item]['img'], // width: ScreenUtil().setWidth(24), // height: ScreenUtil().setWidth(24), // // alignment: Alignment.centerLeft, // ), // ), // SizedBox(height: ScreenUtil().setWidth(10)), // Container( // child: Text( // OrderTypeList[item]["title"], // style: TextStyle( // color: Colours.dark_text_gray, // fontSize: ScreenUtil().setSp(13)), // textAlign: TextAlign.start, // ), // ), // ], // ), // ), // ); // Container( // // color:Colors.yellow, // width: width / 4, // child: FlatButton( // padding: EdgeInsets.all(0), // highlightColor: Colors.white, // splashColor: Colors.white, // child: Container( // // width: 90, // height: ScreenUtil().setWidth(80), // // color: Colors.red, // padding: EdgeInsets.only( // left: ScreenUtil().setWidth(10), // right: ScreenUtil().setWidth(10), // top: ScreenUtil().setWidth(10)), // child: Column( // mainAxisAlignment: MainAxisAlignment.start, // children: [ // Container( // // height: 70, // // color: Colors.red, // child: LoadAssetImage( // // image: AssetImage(i['img']), // initList[item]['img'], // width: ScreenUtil().setWidth(50), // height: ScreenUtil().setWidth(30), // // alignment: Alignment.centerLeft, // ), // ), // SizedBox(height: ScreenUtil().setWidth(10)), // Container( // child: Text( // initList[item]["title"], // style: TextStyle( // color: Colours.red, // fontSize: ScreenUtil().setSp(15)), // textAlign: TextAlign.start, // ), // ), // ]), // ), // onPressed: () { // int nums = item + 1; // String index = nums.toString(); // NavigatorUtils.push( // context, "${WodeRouter.orderPage}?checkType=$index"); // }, // ), // ); }, ).toList(); return TitleCard( title: '我的订单', height: 140, rightText: '查看全部订单', onTapRight: () { NavigatorUtils.push(context, "${WodeRouter.orderPage}?checkType=0"); }, body: Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, // crossAxisAlignment: CrossAxisAlignment.center // crossAxisAlignment: co, children: brandList(context)))); } _iconItem({String title, double size = 24, String icon, Function ontap}) { return InkWell( onTap: ontap, child: Container( // padding: EdgeInsets.only(top: 15), child: Column( // crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( // height: 70, // color: Colors.red, child: LoadAssetImage( // image: AssetImage(i['img']), icon, width: ScreenUtil().setWidth(size), height: ScreenUtil().setWidth(size), // alignment: Alignment.centerLeft, ), ), SizedBox(height: ScreenUtil().setWidth(10)), Container( child: Text( title, style: TextStyle( color: Colours.dark_text_gray, fontSize: ScreenUtil().setSp(13)), textAlign: TextAlign.start, ), ), ], ), ), ); } _applications() { double itemSize = 38; return TitleCard( title: '我的服务', // rightText: '查看全部接单', height: _iszz ? 330 : 260, // onTapRight: () {}, body: Container( child: GridView.count( physics: const NeverScrollableScrollPhysics(), padding: EdgeInsets.only(top: 20), // 内边距 scrollDirection: Axis.vertical, childAspectRatio: 1.1, // 滚动方向 crossAxisSpacing: 10, // 列间距 crossAxisCount: 4, // 每行的个数(Axis.vertic == 横向三个, Axis.horizontal == 竖方向三个) mainAxisSpacing: 10, children: [ _iconItem( title: "打赏记录", icon: "wode/dashang", size: itemSize, ontap: () { Navigator.of(context).push(MaterialPageRoute( builder: (context) => RewardRecordList())); // Navigator.push(context, route) // // RewardRecordList(); // NavigatorUtils.push(context, WodeRouter.collectPage); }, ), _iconItem( title: "收藏", icon: "wode/shoucang", size: itemSize, ontap: () { NavigatorUtils.push(context, WodeRouter.collectPage); }, ), _iconItem( title: "我的视频", icon: "wode/shipin", size: itemSize, ontap: () { NavigatorUtils.push(context, WodeRouter.myVideo); }, ), _iconItem( title: "发票中心", icon: "wode/piao", size: itemSize, ontap: () { NavigatorUtils.push(context, WodeRouter.piaoCenter); }, ), _iconItem( title: "优惠券", icon: "wode/youhuiquan", size: itemSize, ontap: () { NavigatorUtils.push(context, WodeRouter.couponPage); }, ), _iconItem( title: "红包", icon: "wode/hongbao", size: itemSize, ontap: () { NavigatorUtils.push(context, WodeRouter.redbaoPage); }, ), _iconItem( title: "我的消息", icon: "wode/xiaoxi", size: itemSize, ontap: () { NavigatorUtils.push(context, WodeRouter.noticeList); }, ), _iconItem( title: "扫一扫", icon: "wode/qr", size: itemSize, ontap: () { scan(); }, ), _iszz ? _iconItem( title: "专家处罚", icon: "wode/wr", size: itemSize, ontap: () { NavigatorUtils.push(context, WodeRouter.errorRecordList); }, ) : Container(), ], ))); } @override bool get wantKeepAlive => true; } class TitleCard extends StatelessWidget { String title; String rightText; Function onTapRight; double height; Widget body; TitleCard( {this.title, this.rightText, this.onTapRight, this.body, this.height = 120}); @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only(left: 10, right: 10, bottom: 5), decoration: new BoxDecoration( color: Colors.white, //设置四周圆角 角度 borderRadius: BorderRadius.all(Radius.circular(6.0)), ), padding: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 15), height: height, // width: ScreenUtil().setWidth(355), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(title, style: TextStyle( color: Colours.tip_text_black, fontSize: 15, fontWeight: FontWeight.bold)), rightText != null ? InkWell( onTap: onTapRight, child: Row( children: [ Text(rightText, style: TextStyle( color: Colours.dark_text_gray, fontSize: 13)), Icon( Icons.arrow_forward_ios, color: Colours.dark_text_gray, size: 15, ) ], ), ) : Container() ], ), // SizedBox( // height: 15, // ), Expanded(child: body), // body ], ), ); } } class OrderType extends StatelessWidget { OrderType({Key key, this.initList}) : super(key: key); List initList; List brandList(context) => initList.asMap().keys.map( (item) { double width = MediaQuery.of(context).size.width; return Container( // color:Colors.yellow, width: width / 4, child: FlatButton( padding: EdgeInsets.all(0), highlightColor: Colors.white, splashColor: Colors.white, child: Container( // width: 90, height: ScreenUtil().setWidth(80), // color: Colors.red, padding: EdgeInsets.only( left: ScreenUtil().setWidth(10), right: ScreenUtil().setWidth(10), top: ScreenUtil().setWidth(10)), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( // height: 70, // color: Colors.red, child: LoadAssetImage( // image: AssetImage(i['img']), initList[item]['img'], width: ScreenUtil().setWidth(50), height: ScreenUtil().setWidth(30), // alignment: Alignment.centerLeft, ), ), SizedBox(height: ScreenUtil().setWidth(10)), Container( child: Text( initList[item]["title"], style: TextStyle( color: Colours.red, fontSize: ScreenUtil().setSp(15)), textAlign: TextAlign.start, ), ), ]), ), onPressed: () { int nums = item + 1; String index = nums.toString(); NavigatorUtils.push( context, "${WodeRouter.orderPage}?checkType=$index"); }, ), ); }, ).toList(); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.only(top: ScreenUtil().setWidth(5)), child: Wrap( // spacing: 26, alignment: WrapAlignment.spaceBetween, crossAxisAlignment: WrapCrossAlignment.center, children: brandList(context), ), ); } }