29 Flutter Dialog AlertDialog 、SimpleDialog、showModalBottomSheet、showToast
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的更多相关文章
- AlertDialog 、SimpleDialog、 showModalBottomSheet、showToast 自定义 Dialog
// AlertDialog .SimpleDialog.showModalBottomSheet.showToast // 使用showToast安装插件 https://pub.dev/packa ...
- Flutter学习笔记(20)--FloatingActionButton、PopupMenuButton、SimpleDialog、AlertDialog、SnackBar
如需转载,请注明出处:Flutter学习笔记(20)--FloatingActionButton.PopupMenuButton.SimpleDialog.AlertDialog.SnackBar F ...
- 从零学习Fluter(八):Flutter的四种运行模式--Debug、Release、Profile和test以及命名规范
从零学习Fluter(八):Flutter的四种运行模式--Debug.Release.Profile和test以及命名规范 好几天没有跟新我的这个系列文章,一是因为这两天我又在之前的基础上,重新认识 ...
- 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.文件读取.可变参数.自动滚动 之前的介 ...
- flutter 项目中,开发环境、多接口域名、多分支的配置
flutter 项目中,开发环境.多接口域名.多分支的配置 开发环境:配置成多个入口文件.比如:main.dart.main_develop.dart.main_preview.dart 多域名:每个 ...
- Flutter AppBar 自定义顶部导航按钮 图标、颜色 以及 TabBar 定义顶部 Tab 切换
Flutter AppBar 自定义顶部按钮图 标.颜色 属性 描述 leading 在标题前面显示的一个控件,在首页通常显示应用 的 logo;在其他界面通常显示为返回按钮 title 标题,通常显 ...
- 【技术博客】Flutter—使用网络请求的页面搭建流程、State生命周期、一些组件的应用
Flutter-使用网络请求的页面搭建流程.State生命周期.一些组件的应用 使用网络请求的页面搭建流程 在开发APP时,我们常常会遇到如下场景:进入一个页面后,要先进行网络调用,然后使用调用返 ...
- elementUi使用dialog的进行信息的添加、删除表格数据时进行信息提示。删除或者添加成功的信息提示(SpringBoot+Vue+MybatisPlus)
文章目录 1.添加新用户,通过dialog的弹窗形式 1.1 添加的按钮 1.2 调用方法设置窗口可见 1.3 窗口代码 1.4 提交注册信息方法 1.5 使用mybatisPlus方法进行添加信息到 ...
- flutter dialog
flutter Dialog import 'dart:math'; import 'package:flutter/material.dart'; import 'test.dart'; impor ...
随机推荐
- java相关网址汇总(myself)
jar包下载网址 https://www.mvnjar.com/ 或者 https://mvnrepository.com/ 或者 http://www.java2s.com/Open-Source/ ...
- [MVC] 自定义ActionSelector,根据参数选择Action[转载]
很多时候我们会根据UI传入的参数,呈现不同的View.也就是对于同一个Action如何根据请求数据返回不同的View.通常情况下我们会按照如下方法来写,例如: [AcceptVerbs(HttpVer ...
- 除了不要 SELECT * ,程序员使用数据库还应知道的11个技巧
SQL:sum里加条件SELECT SUM( CASE WHEN "V7010" BETWEEN 0 AND 0.1 THEN 1 ELSE 0 END) FROM "C ...
- Jmeter+Selenium结合使用(完整篇)
selenium登录后的cookie交接给接口结合使用 一.下载webdriver插件(包含谷歌和火狐驱动),安装好之后需重启jmeter 二.在配置元件中添加jp@gc - Chrome Drive ...
- AirtestIde的安装(win10)
Airtest 是网易出品的一款基于图像识别和poco控件识别的一款UI自动化测试工具. Airtest IDE是这个项目的一个IDE,就像Eclipse.Pycharm一样,是一个集成开发工具. A ...
- git合并之 merge和rebase
合并有两种方法: git rebase 和git merge 优先用 rebase!!!! 区别: 1. 使用git merge git checkout dev git merge master 或 ...
- Spring事务管理器
1.创建实体和接口 public class Bank { private Integer id; private String name; private String manay; public ...
- JAVA的变量,数据类型与运算符
1. 变量 计算机处理数据,变量被用来存储处理的数据,之所以叫做变量因为你可以改变存储的值.更确切的说,一个变量指向着一块存储特定类型值的地址,换句话说,一个变量有名称.类型和值.一个变量有一个名称, ...
- RabbitMQ的5种模式
队列截图,去rabbitMq.com去找学习文档 =========================================================================== ...
- TensorFlow(二):基本概念以及练习
一:基本概念 1.使用图(graphs)来表示计算任务 2.在被称之为会话(Session)的上下文(context)中执行图 3.使用tensor表示数据 4.通过变量(Variable)维护状态 ...