pubspec.yaml

 fluttertoast: ^3.1.

Dialog.dart

import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart'; class DialogPage extends StatefulWidget {
DialogPage({Key key}) : super(key: key); _DialogPageState createState() => _DialogPageState();
} class _DialogPageState extends State<DialogPage> {
_alertDialog() async {
var result = await showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('提示信息'),
content: Text('你确定要删除吗?'),
actions: <Widget>[
FlatButton(
child: Text('取消'),
onPressed: () {
print('取消');
Navigator.pop(context, "Cancle");
},
),
FlatButton(
child: Text('确定'),
onPressed: () {
Navigator.pop(context, "Ok");
print('确定');
},
)
],
);
});
print(result);
} _simpleDialog() async {
var result = await showDialog(
context: context,
builder: (context) {
return SimpleDialog(
title: Text("选择内容"),
children: <Widget>[
SimpleDialogOption(
child: Text("Option A"),
onPressed: () {
print("Options A");
Navigator.pop(context, "A");
},
),
Divider(),
SimpleDialogOption(
child: Text("Option B"),
onPressed: () {
print("Options B");
Navigator.pop(context, "B");
},
),
Divider(),
SimpleDialogOption(
child: Text("Option C"),
onPressed: () {
print("Options C");
Navigator.pop(context, "C");
},
)
],
);
});
print(result);
} _modelBottomSheet() async {
showModalBottomSheet(
context: context,
builder: (context) {
return Container(
height: ,
child: Column(
children: <Widget>[
ListTile(
title: Text("分享 A"),
onTap: () {
print("分享 A");
Navigator.pop(context, "A");
},
),
Divider(),
ListTile(
title: Text("分享 B"),
onTap: () {
print("分享 B");
Navigator.pop(context, "B");
},
),
Divider(),
ListTile(
title: Text("分享 C"),
onTap: () {
print("分享 C");
Navigator.pop(context, "C");
},
)
],
),
);
});
} _toast() async {
Fluttertoast.showToast(
msg:'提示信息',
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIos: ,
backgroundColor: Colors.black87,
textColor: Colors.white,
fontSize: 16.0
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Dialog'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Text('alert弹出框-AlertDialog'),
onPressed: _alertDialog,
),
SizedBox(height: ),
RaisedButton(
child: Text('select弹出框-SimpleDialog'),
onPressed: _simpleDialog,
),
SizedBox(height: ),
RaisedButton(
child: Text('ActionSheet弹出框-showModalBottomSheet'),
onPressed: _modelBottomSheet,
),
SizedBox(height: ),
RaisedButton(
child: Text('toast-fluttertoast第三方库'),
onPressed: _toast,
),
],
),
),
);
}
}

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. 修改gitlab配置文件指定服务器ip和自定义端口:

    修改gitlab配置文件指定服务器ip和自定义端口: vim /etc/gitlab/gitlab.rb gitlab-ctl reconfiguregitlab-ctl restart 查看与rpm ...

  2. rabbitmq二进制安装

    一.erland的安装 1.首先测试一下是否已经安装了erlang,命令 rpm -qa | grep erlang 2.没有安装则用yum安装 yum install erlang -y 二.下载r ...

  3. 大数据之路week06--day07(Hadoop常用命令)

    一.前述 分享一篇hadoop的常用命令的总结,将常用的Hadoop命令总结如下. 二.具体 1.启动hadoop所有进程start-all.sh等价于start-dfs.sh + start-yar ...

  4. flask 框架 转载:https://cloud.tencent.com/developer/article/1465968

    特点总结: 类名称---->数据库表名 类属性---->数据库字段 类的对象----->数据库表中的一行一行数据 3.ORM操作注意(理解) 1/因为SQLALChemy去app身上 ...

  5. Codeforces Round #533 (Div. 2) E. Helping Hiasat(最大独立集)

    题目链接:https://codeforces.com/contest/1105/problem/E 题意:有 n 个事件,op = 1 表示我可以修改昵称,op = 2 表示一个名为 s_i 的朋友 ...

  6. 学到了林海峰,武沛齐讲的Day20 装饰器

    import time def timmer(func): #func=test 装饰器架构 def wrapper(): start_time=time.time() func() #就是在运行te ...

  7. div与div之间有空隙

    当你使用HTML div块与块的中间不能紧密连接  怎么都解决不了时 使用前效果图 可以在<head></head>中间内容里加一个 * { margin:0; padding ...

  8. CF707D Persistent Bookcase 可持久化线段树

    维护一个二维零一矩阵(n,m<=1000),支持四种操作(不超过10^5次): 将(i,j)置一 将(i,j)置零 将第i行零一反转yu 回到第K次操作前的状态 每次操作后输出全局一共有多少个一 ...

  9. 【原创】go语言学习(十四)IO操作1

    目录: 格式化输入 格式化输出 终端输入输出背后的原理理 bufio包的使用 命令行参数处理理和urfave/cli使用 格式化输入 1.从终端获取⽤用户的输入 格式化输入 fmt.Scan(a …i ...

  10. webpack4温习总结

    webpack是一个模块打包器,可以根据入口文件,随着依赖关系将所有文件打包成js文件. 首先需要node环境,百度一下自己安装 webpack官网地址:https://www.webpackjs.c ...