Flutter 对话框【代码实践】

快来打我* 2023-10-12 08:53 161阅读 0赞

Flutter 对话框【代码实践】

文章目录

  • Flutter 对话框【代码实践】
  • 一、普通对话框
    • 1、示例一:圆角、背景
      • 截图
      • 代码

一、普通对话框

1、示例一:圆角、背景

截图

image-20230601225654498

代码

  1. Center(
  2. child: ElevatedButton(
  3. onPressed: () {
  4. showDialog(
  5. context: context,
  6. builder: (context) {
  7. return AlertDialog(
  8. scrollable: true,
  9. title: const Text("新版本 v1.0.8"),
  10. shape: RoundedRectangleBorder(
  11. borderRadius: BorderRadius.circular(16.0),
  12. ),
  13. backgroundColor: const Color(0XFFE2EAF5),
  14. content: const SelectableText(
  15. "新特性\r\n\r\n- 添加二维码登录;\r\n- 点击导航看按钮刷新;\r\n\r\n修复:\r\n\r\n- 修复进度条;\r\n- 修复显示问题;",
  16. style: TextStyle(fontSize: 14),
  17. ),
  18. actions: [
  19. TextButton(
  20. onPressed: () {
  21. Navigator.pop(context);
  22. },
  23. child: const Text("取消")),
  24. TextButton(
  25. child: const Text("立即更新"),
  26. onPressed: () async {
  27. //自动选择合适系统/abi的版本下载
  28. },
  29. )
  30. ],
  31. );
  32. },
  33. );
  34. },
  35. child: const Text("显示对话框"),
  36. ),
  37. )

发表评论

表情:
评论列表 (有 0 条评论,161人围观)

还没有评论,来说两句吧...

相关阅读