【flutter】下部弹出组件

it2022-05-05  133

/** * 下部弹出框 */ Future<void> _bottomSheet(BuildContext context) async { return showModalBottomSheet( context: context, builder: (BuildContext context) { return _bottomSheetBody(); }, ); } /** * 底部弹出 */ Widget _bottomSheetBody() { return Container( height: 215.0, child: Column( children: <Widget>[ Container( color: Color.fromARGB(50, 180, 180, 180), margin: EdgeInsets.fromLTRB(0, 0, 0, 5), height: 50, child: Center( child: Text( "操作", style: TextStyle( fontSize: 16.0, color: Color.fromARGB(255, 180, 180, 180)), ), )), _buttom_Text( 40.0, " 摄像头 ", "Camera", color_public), Divider(), _buttom_Text( 40.0, " 本地相册 ", "Local", Colors.red), Container( width: MediaQuery.of(context).size.width, height: 10.0, color: Color.fromARGB(50, 180, 180, 180), ), _buttom_Text( 40.0, " 取消 ", "Cancel", Colors.black), ], ), ); } /** * 下部弹出普通组件 */ _buttom_Text(double heigh, String text, String type, Color color) { return GestureDetector( onTap: () { switch (type) { case "Camera": { //摄像头 Navigator.of(context).pop(); getImage(type); /*Navigator.of(context).push( CustomRoute(EditGreenhouse(id: id), customRoute));*/ break; } case "Local": { //本地 Navigator.of(context).pop(); getImage(type); /*Navigator.of(context).push( CustomRoute(EditPlant(id: id), customRoute));*/ break; } case "Cancel": { //取消 Navigator.of(context).pop(); break; } } }, child: Container( height: heigh, width: MediaQuery.of(context).size.width, child: Center( child: Text( text, style: TextStyle(fontSize: 16.0, color: color), ), ), )); }

最新回复(0)