// AlertDialog 、SimpleDialog、showModalBottomSheet、showToast
// 使用showToast安装插件 https://pub.dev/packages/fluttertoast
Fluttertoast.showToast( msg: "This is Short Toast", toastLength: Toast.LENGTH_SHORT, timeInSecForIos: 1); // 改变弹窗内的值
StatefulBuilder(
builder: (context, changeState) {
return '内容'
},
)
// 点击背景消失
showDialog(
context: context,
builder: (context) {
return CupertinoDialog (
child: Text('zxcvbnm123456', style: TextStyle(fontSize: Screen.width(30), decoration: TextDecoration.none, color: Colors.black, fontWeight: FontWeight.normal)));
}
);
// 点击背景不消失
showCupertinoDialog(
context: context,
builder: (context) {
return CupertinoDialog (
child: Text('zxcvbnm123456', style: TextStyle(fontSize: Screen.width(30), decoration: TextDecoration.none, color: Colors.black, fontWeight: FontWeight.normal)));
}
);
import 'package:flutter/material.dart';
import 'myDialog.dart'; class DialogPage extends StatefulWidget{
DialogPage({Key key});
_Dialog createState() => _Dialog();
} class _Dialog extends State {
@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(
title: Text('Dialog')
),
body: ListView(
children: <Widget>[
RaisedButton(
child: Text('AlertDialog'),
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('提示'),
content: Text('确定要取消吗'),
actions: <Widget>[
FlatButton(child: Text('取消'), onPressed: () {Navigator.pop(context, '222');},),
FlatButton(child: Text('确定'), onPressed: () {Navigator.pop(context, '222');},),
],
);
}
);
},
),
RaisedButton(
child: Text('弹出选择卡'),
onPressed: () {
showDialog(
context: context,
builder: (context) {
return SimpleDialog(
title: Text('选择卡'),
children: <Widget>[
SimpleDialogOption(child: Text('A'), onPressed: () { Navigator.pop(context);},),
SimpleDialogOption(child: Text('B'), onPressed: () { Navigator.pop(context);},),
SimpleDialogOption(child: Text('C'), onPressed: () { Navigator.pop(context);},),
],
);
}
);
},
),
RaisedButton(
child: Text('弹出自定义'),
onPressed: () {
showDialog(
context: context,
builder: (context) {
return MyDialog(title:"关于我们", content:"关于我们");
}
);
},
)
],
)
);
}
}
// 自定义dialog
import 'dart:async'; import 'package:flutter/material.dart';
//MyDialog(title:"关于我们", content:"关于我们"); 引入文件 然后调用方法 class MyDialog extends Dialog {
String title;
String content; MyDialog({this.title="",this.content=""}); _showTimer(context){
var timer;
timer = Timer.periodic(
Duration(milliseconds: 3000), (t) { print('关闭');
Navigator.pop(context);
t.cancel(); //取消定时器 timer.cancel();
});
} @override
Widget build(BuildContext context) { _showTimer(context); // TODO: implement build
return Material(
type: MaterialType.transparency,
child: Center(
child: Container(
height: 300,
width: 300,
color: Colors.white,
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.all(10),
child: Stack(
children: <Widget>[
Align(
alignment: Alignment.center,
child: Text("${this.title}"),
),
Align(
alignment: Alignment.centerRight,
child: InkWell(
child: Icon(Icons.close),
onTap: (){
Navigator.pop(context);
},
),
)
],
),
),
Divider(),
Container(
padding: EdgeInsets.all(10),
width: double.infinity,
child: Text("${this.content}",textAlign: TextAlign.left),
)
],
), )),
);
}
}

AlertDialog 、SimpleDialog、 showModalBottomSheet、showToast 自定义 Dialog的更多相关文章

  1. 30 Flutter自定义Dialog

    MyDialog.dart import 'dart:async'; import 'package:flutter/material.dart'; class MyDialog extends Di ...

  2. android 自定义Dialog背景透明及显示位置设置

    先贴一下显示效果图,仅作参考: 代码如下: 1.自定义Dialog public class SelectDialog extends AlertDialog{ public SelectDialog ...

  3. Android 开发之自定义Dialog及UI的实现

    我们在开发中,经常会自定义Dialog,因为原生的AlertDialog无法满足我们的需求,这个时候就需要自定义Dialog,那么如何自定义呢,其实不难,就是有点繁琐而已.也就是自定义一个UI的xml ...

  4. 非自定义和自定义Dialog的介绍!!!

    一.非自定义Dialog的几种形式介绍 转自:http://www.kwstu.com/ArticleView/kwstu_20139682354515 前言 对话框对于应用也是必不可少的一个组件,在 ...

  5. 自定义dialog自动弹出软键盘

    1.解决无法弹出输入法: 在show()方法调用之前,用dialog.setView(new EditText(context))添加一个空的EditText,由于是自定义的AlertDialog,有 ...

  6. Android自定义 Dialog 对话框

    Android自定义Dialoghttp://www.cnblogs.com/and_he/archive/2011/09/16/2178716.html Android使用自定义AlertDialo ...

  7. 自定义Dialog布局的弹窗功能的简单实现

    package com.loaderman.dialogdemo; import android.os.Bundle; import android.support.v7.app.AlertDialo ...

  8. android 自定义Dialog去除黑色边框

    在自定义Dialog时显示的界面中老是有黑色的边框,下面就介绍使用style去除黑色边框方法. 首先在values/styles定义自定义样式: <style name="MyDial ...

  9. Android—自定义Dialog

    在 Android 日常的开发中,Dialog 使用是比较广泛的.无论是提示一个提示语,还是确认信息,还是有一定交互的(弹出验证码,输入账号密码登录等等)对话框. 而我们去看一下原生的对话框,虽然随着 ...

随机推荐

  1. 分类问题(三)混淆矩阵,Precision与Recall

    混淆矩阵 衡量一个分类器性能的更好的办法是混淆矩阵.它基于的思想是:计算类别A被分类为类别B的次数.例如在查看分类器将图片5分类成图片3时,我们会看混淆矩阵的第5行以及第3列. 为了计算一个混淆矩阵, ...

  2. 利用Master库spt_values表 连续数字

    SELECT CONVERT ( ), dateadd(d, number, GETDATE()), ) AS every_time FROM master..spt_values n WHERE n ...

  3. phpstorm更换主题

    打开PhpStorm,File -- Settings -- Editor -- Color Scheme --General选择你喜欢的风格进行更改,选择完成后单击Apply

  4. 154.Ajax处理csrf防御

    在普通的form表单中采用post请求提交数据,可以在form表单的method=post的form标签下面,添加一个csrf_token标签{% csrf_token %},或者是直接手动的添加一个 ...

  5. Python警告:InsecureRequestWarning、InsecurePlatformWarning、SNIMissingWarning

    SSL警告 urllib3将基于证书验证支持的级别发出几种不同的警告.这些警告表示特定情况,可以通过不同方式解决. InsecureRequestWarning 当在未启用证书验证的情况下对HTTPS ...

  6. Pycharm操作数据库

    Pymysql 用于连接mysql数据库 连接数据库 data_ip = "192.168.34.128" data_name = "lch" data_pwd ...

  7. liunx 中设置zookeeper 自启动(service zookeeper does not support chkconfig)

    在liunx 上设置zookeeper 自启动 1.进入目录 cd /etc/init.d 2.创建一个文件 vim zookeeper 3.编辑zookeepr 文件 连接liunx使用的软件是fi ...

  8. 在sql server中如何检测一个字符串中是否包含另一个字符串

    select CHARINDEX('456','123456')   SQL语句使用CHARINDEX函数,来测试一个字符串中是否包含另一个字符串中的方法: 一.CHARINDEX函数介绍 1.函数功 ...

  9. django 搭建一个投票类网站(二)

    前一篇讲了创建一个工程和一个polls的应用程序,以及配置了数据库. 这篇就继续讲吧 1.django admin模块 admin模块是django自带的模块,他让开发者可以不用管写任何代码的情况下就 ...

  10. AcWing 789. 数的范围 二分+模板

    https://www.acwing.com/problem/content/791/ #include<bits/stdc++.h> using namespace std; ; int ...