import 'package:deus_app/common/style/gsy_style.dart'; import 'package:deus_app/common/utils/ConstantString.dart'; import 'package:flutter/material.dart'; import '../model/drop_menu_item.dart'; class PatrolJobDrawer extends StatefulWidget { final _CallBack callback; const PatrolJobDrawer({super.key, required this.callback}); @override State createState() { return _patrolJobDrawer(); } } DropMenuItem boy = DropMenuItem('男', 1); DropMenuItem girl = DropMenuItem('女', 2); DropMenuItem sexSelect = DropMenuItem('男', 1); List sexMenuItems = [boy, girl]; typedef _CallBack = void Function(int selectIndex, String selectStr); class _patrolJobDrawer extends State { @override Widget build(BuildContext context) { return Drawer( child: MediaQuery.removePadding( context: context, //移除抽屉菜单顶部默认留白 removeTop: true, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(top: 50.0, left: 10, right: 10), child: Row(children: [ Expanded( flex: 2, child: Text( '任务名称', style: TextStyle( color: Colors.black, fontSize: GSYConstant.minTextSize, fontWeight: FontWeight.bold, ), ), ), Expanded( child: Container( height: 40, child: TextField( decoration: InputDecoration( border: OutlineInputBorder(), ), style: TextStyle(fontSize: 14), onChanged: (value) { _name = value; }, ), ), flex: 7, ), ]), ), Padding( padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10), child: Row(children: [ Expanded( flex: 2, child: Text( '任务编号', style: TextStyle( color: Colors.black, fontSize: GSYConstant.minTextSize, fontWeight: FontWeight.bold, ), ), ), Expanded( child: Container( height: 40, child: TextField( decoration: InputDecoration(border: OutlineInputBorder()), style: TextStyle(fontSize: 14), onChanged: (value) { _number = value; }, ), ), flex: 7, ), ]), ),Padding( padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10), child: Row(children: [ Expanded( flex: 2, child: Text( '计划名称', style: TextStyle( color: Colors.black, fontSize: GSYConstant.minTextSize, fontWeight: FontWeight.bold, ), ), ), Expanded( child: Container( height: 40, child: TextField( decoration: InputDecoration(border: OutlineInputBorder()), style: TextStyle(fontSize: 14), onChanged: (value) { _planName = value; }, ), ), flex: 7, ), ]), ),Padding( padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10), child: Row(children: [ Expanded( flex: 2, child: Text( '计划编号', style: TextStyle( color: Colors.black, fontSize: GSYConstant.minTextSize, fontWeight: FontWeight.bold, ), ), ), Expanded( child: Container( height: 40, child: TextField( decoration: InputDecoration(border: OutlineInputBorder()), style: TextStyle(fontSize: 14), onChanged: (value) { _planNumber = value; }, ), ), flex: 7, ), ]), ), Padding( padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10), child: Row(children: [ Expanded( flex: 2, child: Text( '任务状态', style: TextStyle( color: Colors.black, fontSize: GSYConstant.minTextSize, fontWeight: FontWeight.bold, ), ), ), Expanded( flex: 7, child: Container( child: dropDownButtonsColumn(sexMenuItems, '性别', jobMenu), ), ), ]), ), ], ), ), ); } Widget dropDownButtonsColumn(List list, String hint, DropMenuItem select) { return Container( height: 40, //gives the height of the dropdown button width: MediaQuery.of(context).size.width, //gives the width of the dropdown button decoration: BoxDecoration( border: new Border.all( color: Colors.grey, //边框颜色 width: 1.0, //边框粗细 ), borderRadius: const BorderRadius.all(const Radius.circular(4.0)), //边框的弧度 ), // padding: const EdgeInsets.symmetric(horizontal: 13), //you can include padding to control the menu items child: Theme( data: Theme.of(context).copyWith( // canvasColor: Colors.white, // background color for the dropdown items buttonTheme: ButtonTheme.of(context).copyWith( alignedDropdown: true, //If false (the default), then the dropdown's menu will be wider than its button. )), child: DropdownButtonHideUnderline( // to hide the default underline of the dropdown button child: DropdownButton( iconEnabledColor: Color(0xFF595959), // icon color of the dropdown button items: list.map((dropMenuItem) { return DropdownMenuItem( value: dropMenuItem.label, child: Text( dropMenuItem.label, style: TextStyle(fontSize: 15), ), ); }).toList(), hint: Text( hint, style: TextStyle(fontSize: 15), ), // setting hint onChanged: (String? value) { setState(() { select.label = value; // saving the selected value }); }, value: select.label, // displaying the selected value ), )), ); } String _name = '',_number = '', _planName = '', _planNumber = ''; int _status = 1,_termType = 1; DropMenuItem jobMenu = DropMenuItem('男', 1); }