// 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. tcolorbox 宏包简明教程

    嗯,我消失好几天了.那么,我都在做什么呢?没错,就是写这篇文章了.这篇文章写起来着实有些费神了.于是,如果你觉得这篇文章对你有帮助,不妨扫描文末的二维码,适量赞助一下哦~! tcolorbox 宏包是 ...

  2. Struts2学习-struts执行过程简述

    1.web.xml <web-app> <filter> <filter-name>struts2</filter-name> <filter-c ...

  3. C# SDO_GEOMETRY

    OracleParameter endGeometry = cmd.CreateParameter(); endGeometry.OracleDbType = OracleDbType.Object; ...

  4. Selenium3+python自动化012+日志logging基本用法、高级用法

    1.关键字: login 登录 log 日志 logging python日志模块 2.什么叫日志: 日志用来记录用户行为或者代码的执行过程 3.日志使用的地方: 1.排错的时候需要打印很多细节来帮助 ...

  5. 海康 - 终端服务器 - TS-5012-F

    简介 型号描述 主要特点 典型应用 技术参数        型号 参数 TS-5012-F (1T) TS-5012-F (2T) TS-5012-F (4T) TS-5012-F (8T) 系统参数 ...

  6. oracle三个网络配置文件(listener.ora、tnsname.ora、sqlnet.ora)的作用

    oracle网络配置 三个配置文件 listener.ora.sqlnet.ora.tnsnames.ora ,都是放在$ORACLE_HOME\network\admin目录下. 1.  sqlne ...

  7. python threading2种调用方式实例

    1.认识GIL: 说到GIL一直是代码专家们一直以来想要解决的问题,也是被许多程序员诟病的,下面带领大家看下官方threading模块document中如何去描述对于GIL这个全局解释器锁的:http ...

  8. ETag使用

    关于ETag相关知识: https://blog.csdn.net/kikikind/article/details/6266101  https://blog.csdn.net/jkxiaoxing ...

  9. C++-POJ2955-Brackets[DP]

    题意就是,找出最长合法子括号序列 容易想到设f[l][r]为l~r的最长合法子括号序列的长度 然后从短的状态往长的状态枚举,不断更新答案就可以了 //#include<bits/stdc++.h ...

  10. 安装python包时遇到"error: Microsoft Visual C++ 9.0 is required"的简答(Python2.7)

    简答 在Windows下用pip安装Scrapy报如下错误, error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall ...