import 'package:flutter/material.dart'; import 'commonFun.dart'; import 'package:flutter/services.dart'; //输入视频地址对话框 class customDialogB extends Dialog { String title; String content; String url; customDialogB({this.title = "", this.content = "", this.url = ''}); // Widget getButton({double width = 60.0, double height = 30.0, RaisedButton raisedButton}) { // return ButtonTheme( // minWidth: width, //设置最小宽度 // height: height, // //colorScheme: , // buttonColor: Colors.white60, // child: raisedButton, // ); // } Widget getBtnSizeX({@required text, width = 60.0, height = 30.0, onPressedFun}) { return Container( color: Colors.white12, //onPressedFun为null时无效 width: width, height: height, child: RaisedButton( padding: EdgeInsets.all(0), textColor: Colors.black, child: Text(text), onPressed: onPressedFun, ), ); } @override Widget build(BuildContext context) { Size mediaSize = MediaQuery.of(context).size; // 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.95, //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: [ getBtnSizeX( text: "粘贴", onPressedFun: () async { ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain); myController.text = data.text; }, ), // getButton( // raisedButton: RaisedButton( // onPressed: () async { // ClipboardData data = // await Clipboard.getData(Clipboard.kTextPlain); // myController.text = data.text; // }, // child: Text("粘贴"), // ), // ), getBtnSizeX( text: "获取", onPressedFun: () async { myController.text = url; }, ), // getButton( // raisedButton: RaisedButton( // onPressed: () async { // myController.text = url; // }, // child: Text("获取"), // ), // ), getBtnSizeX( text: "清除", onPressedFun: () { myController.clear(); }, ), // getButton( // raisedButton: RaisedButton( // onPressed: () { // myController.clear(); // }, // child: Text("清除"), // ), // ), getBtnSizeX( text: "播放", onPressedFun: () { //Navigator.of(context).pop() //关闭弹框,这样关闭会导致视频播放停止,无法开始 if ("" != myController.text) { urlnew = url = myController.text; } Navigator.pop(context, url); //关闭弹框,播放输入视频地址 }, ), // getButton( // raisedButton: RaisedButton( // onPressed: () { // //Navigator.of(context).pop() //关闭弹框,这样关闭会导致视频播放停止,无法开始 // if ("" != myController.text) { // urlnew = url = myController.text; // } // Navigator.pop(context, url); //关闭弹框,播放输入视频地址 // }, // child: Text("播放"), // ), // ), ], ), ], ), ), ), ), onWillPop: () { // 屏蔽点击返回键的操作 //player.pause(); Navigator.pop(context, url); }, ); } }