import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'util/models.dart'; // ignore: must_be_immutable class ShowLineModal extends Dialog { List lineList = []; final childCallback; ShowLineModal( {Key key, @required this.lineList, @required this.childCallback}) : super(key: key); String lineId = '-1'; @override Widget build(BuildContext context) { return new Material( //创建透明层 type: MaterialType.transparency, //透明类型 child: new Center( //保证控件居中效果 child: Container( width: ScreenUtil.getInstance().setWidth(600), height: ScreenUtil.getInstance().setHeight(345), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(8))), child: new Container( child: new Column( children: [ Container( height: ScreenUtil.getInstance().setHeight(255), decoration: BoxDecoration( border: Border( bottom: BorderSide( width: 1, color: Color.fromRGBO(151, 151, 151, 0.27)))), child: LineWidget( lineList: lineList, callback: (val) { lineId = val.toString(); }, )), Expanded( flex: 1, child: Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( flex: 1, child: InkWell( child: Container( decoration: BoxDecoration( border: Border( right: BorderSide( width: 1, color: Color.fromRGBO( 151, 151, 151, 0.27))), ), child: Center( child: Text( '取消', style: TextStyle( fontSize: ScreenUtil.getInstance() .setSp(32), color: Color.fromRGBO(64, 98, 254, 1)), ), )), onTap: () { Navigator.pop(context); }, )), Expanded( flex: 1, child: InkWell( child: Container( decoration: BoxDecoration( border: Border( right: BorderSide( width: 1, color: Color.fromRGBO( 151, 151, 151, 0.27))), ), child: Center( child: Text( '确定', style: TextStyle( fontSize: ScreenUtil.getInstance() .setSp(32), color: Color.fromRGBO(64, 98, 254, 1)), ), )), onTap: () { Navigator.pop(context); childCallback(lineId); }, )), ], ), )) ], ), ), ), ), ); } } class LineWidget extends StatefulWidget { final List lineList; final callback; LineWidget({Key key, this.lineList, this.callback}) : super(key: key); _LineWidgetState createState() => _LineWidgetState(); } class _LineWidgetState extends State { @override Widget build(BuildContext context) { return Column( children: [ Container( height: ScreenUtil.getInstance().setHeight(60), child:Center( child: Text('请选择线路'), ), ), Expanded( flex: 1, child: ListView.builder( itemCount: widget.lineList.length, itemBuilder: (BuildContext context, int index) { return InkWell( child: Container( height: ScreenUtil.getInstance().setHeight(100), padding: EdgeInsets.fromLTRB(30, 0, 30, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( widget.lineList[index].lineName, style: TextStyle( fontSize: ScreenUtil.getInstance().setSp(35)), ), Icon(Icons.check,color: widget.lineList[index].checkedStatus?Colors.black:Colors.white,) ], ), ), onTap: (){ setState(() { for(int i=0;i