底部弹出
getx模式
| Get.bottomSheet( |
| isScrollControlled: false, |
| backgroundColor: AppColors.primaryBackground, |
| isDismissible: false, |
| enableDrag: false, |
| Container( |
| height: 500, |
| padding: EdgeInsets.all(8.0), |
| width: double.infinity, |
| decoration: const ShapeDecoration( |
| color: Colors.white, |
| shape: RoundedRectangleBorder( |
| borderRadius: BorderRadius.only( |
| topLeft: Radius.circular(16), |
| topRight: Radius.circular(16), |
| ), |
| ), |
| ), |
| |
| child: Column( |
| mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| children: [ |
| Container( |
| child: Row( |
| children: [ |
| Container( |
| child: Expanded( |
| child: Stack( |
| alignment: Alignment.center, |
| children: [ |
| Text("title"), |
| Positioned( |
| right: 16, |
| child: IconButton( |
| onPressed: () { |
| Get.back(); |
| }, |
| icon: const Icon( |
| Icons.highlight_off, |
| ), |
| )) |
| ], |
| )), |
| ) |
| ], |
| ), |
| ), |
| ], |
| ), |
| )); |
原生模式
| Container _buildBottomSheet(context) { |
| return Container( |
| height: 400, |
| padding: const EdgeInsets.all(8.0), |
| decoration: BoxDecoration( |
| border: Border.all(color: Colors.transparent, width: 2.0), |
| borderRadius: BorderRadius.circular(16.0), |
| color: Colors.white |
| ), |
| child:, |
| ); |
| } |
原生模式使用方法:
| onTap:(){ |
| showModalBottomSheet<void>( |
| context: context, |
| enableDrag:false, |
| builder: (BuildContext context) { |
| return _buildBottomSheet(context); |
| }); |
| }, |
dialog
| showDialog(context: context, |
| barrierDismissible:false, |
| builder: (context) { |
| return Theme( |
| data: ThemeData( |
| dialogBackgroundColor: Colors.white, |
| ), |
| child: AlertDialog( |
| content: Container( |
| width: 100, |
| height: 100, |
| child: Center( |
| child: Text("是否保存为草稿?"), |
| ), |
| ), |
| actionsAlignment:MainAxisAlignment.spaceAround, |
| actions:[ |
| TextButton( |
| onPressed: (){ |
| onDraftBoxSave(); |
| toastInfo(text: "保存成功"); |
| Get.close(2); |
| }, |
| child: Text("保存并退出") |
| ), |
| TextButton( |
| onPressed: (){ |
| |
| Get.close(2); |
| }, |
| child: Text("直接退出",style: TextStyle( |
| color: AppColors.primaryText |
| ),) |
| ), |
| |
| ], |
| ), |
| ); |
| }); |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 提示词工程——AI应用必不可少的技术
· 地球OL攻略 —— 某应届生求职总结
· 字符编码:从基础到乱码解决
· SpringCloud带你走进微服务的世界