import 'package:flutter/material.dart'; import 'commonFun.dart'; //修改视频地址对话框 class CustomDialogD extends Dialog { String title; String content; String url; CustomDialogD({this.title = "", this.content = "", this.url = ''}); @override Widget build(BuildContext context) { Size mediaSize = MediaQuery.of(context).size; myController.text = content; //为TextField赋初始值 // TODO: implement build return WillPopScope( child: Material( type: MaterialType.transparency, child: Container( alignment: Alignment(0, -0.7), child: Container( // height: 260, // width: 300, height: mediaSize.height * 0.4, width: mediaSize.width * 0.85, //color: Colors.white, //Cannot provide both a color and a decoration decoration: BoxDecoration( color: Colors.white, //border: Border.all(color: Colors.blue, width: 1.0), borderRadius: BorderRadius.all( Radius.circular(2), ), ), child: Column( children: [ Padding( padding: EdgeInsets.fromLTRB(10, 10, 10, 0), child: Stack( children: [ Align( alignment: Alignment.center, child: Text( "${this.title}", style: TextStyle( fontSize: 15.0, ), ), ), Align( alignment: Alignment.centerRight, child: InkWell( child: Icon(Icons.close), onTap: () { Navigator.pop(context, url); }, ), ) ], ), ), Divider(), Container( padding: EdgeInsets.fromLTRB(20, 10, 20, 10), width: double.infinity, child: TextField( maxLines: 4, controller: myController, autofocus: false, //不会自动打开输入键盘 decoration: InputDecoration( fillColor: Theme.of(context).hoverColor, filled: true, hintText: 'Media Url', border: OutlineInputBorder() //labelText: 'Media Url', ), ), ), SizedBox(height: 10), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ RaisedButton( onPressed: () { myController.text = url; }, child: Text("获取"), ), RaisedButton( onPressed: () { myController.clear(); }, child: Text("清除"), ), RaisedButton( child: Text("确认"), onPressed: () async { Navigator.pop(context, url); //关闭弹框,播放输入视频地址 }, ) ], ), ], ), ), ), ), onWillPop: () { // 屏蔽点击返回键的操作 //player.pause(); Navigator.pop(context, url); }, ); } }