pubspec.yaml

  1. fluttertoast: ^3.1.

Dialog.dart

  1. import 'package:flutter/material.dart';
  2. import 'package:fluttertoast/fluttertoast.dart';
  3.  
  4. class DialogPage extends StatefulWidget {
  5. DialogPage({Key key}) : super(key: key);
  6.  
  7. _DialogPageState createState() => _DialogPageState();
  8. }
  9.  
  10. class _DialogPageState extends State<DialogPage> {
  11. _alertDialog() async {
  12. var result = await showDialog(
  13. context: context,
  14. builder: (context) {
  15. return AlertDialog(
  16. title: Text('提示信息'),
  17. content: Text('你确定要删除吗?'),
  18. actions: <Widget>[
  19. FlatButton(
  20. child: Text('取消'),
  21. onPressed: () {
  22. print('取消');
  23. Navigator.pop(context, "Cancle");
  24. },
  25. ),
  26. FlatButton(
  27. child: Text('确定'),
  28. onPressed: () {
  29. Navigator.pop(context, "Ok");
  30. print('确定');
  31. },
  32. )
  33. ],
  34. );
  35. });
  36. print(result);
  37. }
  38.  
  39. _simpleDialog() async {
  40. var result = await showDialog(
  41. context: context,
  42. builder: (context) {
  43. return SimpleDialog(
  44. title: Text("选择内容"),
  45. children: <Widget>[
  46. SimpleDialogOption(
  47. child: Text("Option A"),
  48. onPressed: () {
  49. print("Options A");
  50. Navigator.pop(context, "A");
  51. },
  52. ),
  53. Divider(),
  54. SimpleDialogOption(
  55. child: Text("Option B"),
  56. onPressed: () {
  57. print("Options B");
  58. Navigator.pop(context, "B");
  59. },
  60. ),
  61. Divider(),
  62. SimpleDialogOption(
  63. child: Text("Option C"),
  64. onPressed: () {
  65. print("Options C");
  66. Navigator.pop(context, "C");
  67. },
  68. )
  69. ],
  70. );
  71. });
  72. print(result);
  73. }
  74.  
  75. _modelBottomSheet() async {
  76. showModalBottomSheet(
  77. context: context,
  78. builder: (context) {
  79. return Container(
  80. height: ,
  81. child: Column(
  82. children: <Widget>[
  83. ListTile(
  84. title: Text("分享 A"),
  85. onTap: () {
  86. print("分享 A");
  87. Navigator.pop(context, "A");
  88. },
  89. ),
  90. Divider(),
  91. ListTile(
  92. title: Text("分享 B"),
  93. onTap: () {
  94. print("分享 B");
  95. Navigator.pop(context, "B");
  96. },
  97. ),
  98. Divider(),
  99. ListTile(
  100. title: Text("分享 C"),
  101. onTap: () {
  102. print("分享 C");
  103. Navigator.pop(context, "C");
  104. },
  105. )
  106. ],
  107. ),
  108. );
  109. });
  110. }
  111.  
  112. _toast() async {
  113. Fluttertoast.showToast(
  114. msg:'提示信息',
  115. toastLength: Toast.LENGTH_SHORT,
  116. gravity: ToastGravity.CENTER,
  117. timeInSecForIos: ,
  118. backgroundColor: Colors.black87,
  119. textColor: Colors.white,
  120. fontSize: 16.0
  121. );
  122. }
  123. @override
  124. Widget build(BuildContext context) {
  125. return Scaffold(
  126. appBar: AppBar(
  127. title: Text('Dialog'),
  128. ),
  129. body: Center(
  130. child: Column(
  131. mainAxisAlignment: MainAxisAlignment.center,
  132. children: <Widget>[
  133. RaisedButton(
  134. child: Text('alert弹出框-AlertDialog'),
  135. onPressed: _alertDialog,
  136. ),
  137. SizedBox(height: ),
  138. RaisedButton(
  139. child: Text('select弹出框-SimpleDialog'),
  140. onPressed: _simpleDialog,
  141. ),
  142. SizedBox(height: ),
  143. RaisedButton(
  144. child: Text('ActionSheet弹出框-showModalBottomSheet'),
  145. onPressed: _modelBottomSheet,
  146. ),
  147. SizedBox(height: ),
  148. RaisedButton(
  149. child: Text('toast-fluttertoast第三方库'),
  150. onPressed: _toast,
  151. ),
  152. ],
  153. ),
  154. ),
  155. );
  156. }
  157. }

29 Flutter Dialog AlertDialog 、SimpleDialog、showModalBottomSheet、showToast的更多相关文章

  1. AlertDialog 、SimpleDialog、 showModalBottomSheet、showToast 自定义 Dialog

    // AlertDialog .SimpleDialog.showModalBottomSheet.showToast // 使用showToast安装插件 https://pub.dev/packa ...

  2. Flutter学习笔记(20)--FloatingActionButton、PopupMenuButton、SimpleDialog、AlertDialog、SnackBar

    如需转载,请注明出处:Flutter学习笔记(20)--FloatingActionButton.PopupMenuButton.SimpleDialog.AlertDialog.SnackBar F ...

  3. 从零学习Fluter(八):Flutter的四种运行模式--Debug、Release、Profile和test以及命名规范

    从零学习Fluter(八):Flutter的四种运行模式--Debug.Release.Profile和test以及命名规范 好几天没有跟新我的这个系列文章,一是因为这两天我又在之前的基础上,重新认识 ...

  4. Creating Dialogbased Windows Application (4) / 创建基于对话框的Windows应用程序(四)Edit Control、Combo Box的应用、Unicode转ANSI、Open File Dialog、文件读取、可变参数、文本框自动滚动 / VC++, Windows

    创建基于对话框的Windows应用程序(四)—— Edit Control.Combo Box的应用.Unicode转ANSI.Open File Dialog.文件读取.可变参数.自动滚动 之前的介 ...

  5. flutter 项目中,开发环境、多接口域名、多分支的配置

    flutter 项目中,开发环境.多接口域名.多分支的配置 开发环境:配置成多个入口文件.比如:main.dart.main_develop.dart.main_preview.dart 多域名:每个 ...

  6. Flutter AppBar 自定义顶部导航按钮 图标、颜色 以及 TabBar 定义顶部 Tab 切换

    Flutter AppBar 自定义顶部按钮图 标.颜色 属性 描述 leading 在标题前面显示的一个控件,在首页通常显示应用 的 logo;在其他界面通常显示为返回按钮 title 标题,通常显 ...

  7. 【技术博客】Flutter—使用网络请求的页面搭建流程、State生命周期、一些组件的应用

    Flutter-使用网络请求的页面搭建流程.State生命周期.一些组件的应用 使用网络请求的页面搭建流程 ​ 在开发APP时,我们常常会遇到如下场景:进入一个页面后,要先进行网络调用,然后使用调用返 ...

  8. elementUi使用dialog的进行信息的添加、删除表格数据时进行信息提示。删除或者添加成功的信息提示(SpringBoot+Vue+MybatisPlus)

    文章目录 1.添加新用户,通过dialog的弹窗形式 1.1 添加的按钮 1.2 调用方法设置窗口可见 1.3 窗口代码 1.4 提交注册信息方法 1.5 使用mybatisPlus方法进行添加信息到 ...

  9. flutter dialog

    flutter Dialog import 'dart:math'; import 'package:flutter/material.dart'; import 'test.dart'; impor ...

随机推荐

  1. Python 写入训练日志文件并控制台输出

    1. 背景 在深度学习的任务中,通常需要比较长时间的训练,因此我们会选择离开电脑.笔者在跟踪模型表现, 观察模型accuracy 以及 loss 的时候,比较传统的方法是在控制台print输出或者直接 ...

  2. 助教培训第四次作业——熟练掌握GitHub及Git的使用方法

    助教培训第四次作业——熟练掌握GitHub及Git的使用方法 1.Git 命令的理解和使用 常用的Git命令可以查看官方文档,官方文档的网址:https://git-scm.com/docs .虽然是 ...

  3. python函数式编程-偏向函数

    Python的functools模块提供了很多有用的功能,其中一个就是偏函数(Partial function).要注意,这里的偏函数和数学意义上的偏函数不一样. 在介绍函数参数的时候,我们讲到,通过 ...

  4. k8s的Pod状态和生命周期管理

    Pod状态和生命周期管理   一.什么是Pod? 二.Pod中如何管理多个容器? 三.使用Pod 四.Pod的持久性和终止 五.Pause容器 六.init容器 七.Pod的生命周期 (1)Pod p ...

  5. 第七届蓝桥杯C/C++程序设计本科B组决赛 ——机器人塔(程序大题)

    机器人塔 X星球的机器人表演拉拉队有两种服装,A和B.他们这次表演的是搭机器人塔. 类似: A B B A B A A A B B B B B A BA B A B B A 队内的组塔规则是: A 只 ...

  6. export default 和 export 的使用方式

    node中导入模块:var 名称 = require('模块标识符') node中向外暴露成员的形式:module.exports = {} 在ES6中,也通过规范的形式,规定了ES6中如何导入和导出 ...

  7. 2019-2020-1 20199301《Linux内核原理与分析》第二周作业

    第二周Linux学习笔记 文件打包与解压缩 tar工具打包 tar的解压和压缩都是同一个命令,只需参数不同,使用较方便. 创建一个包时文件名必须紧跟在 -f 之后,解包一个文件(-x参数)到指定路径的 ...

  8. Java8新特性--日期和时间API

    如何正确处理时间 现实生活的世界里,时间是不断向前的,如果向前追溯时间的起点,可能是宇宙出生时,又或是是宇宙出现之前, 但肯定是我们目前无法找到的,我们不知道现在距离时间原点的精确距离.所以我们要表示 ...

  9. js手机点击图片放大

    点击每个图片获取到对应的img的url链接,再把链接给一个空img以此来实现 最终效果:

  10. BZOJ3678 wangxz与OJ (平衡树 无旋treap)

    题面 维护一个序列,支持以下操作: 1.在某个位置插入一段值连续的数. 2.删除在当前序列位置连续的一段数. 3.查询某个位置的数是多少. 题解 显然平衡树,一个点维护一段值连续的数,如果插入或者删除 ...