import 'package:flutter/material.dart';
import 'LoadingDialog.dart';
import 'package:fluttertoast/fluttertoast.dart';
class BaseWidget extends StatefulWidget {
@override
State createState() => BaseWidgetState();
}
class BaseWidgetState extends State {
BuildContext context;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
this.context=context;
return Scaffold(
appBar: appbar("测试",null),
body: new Container(
color: Color.fromRGBO(0, 0, 0, 0),
),
);
}
void showLoading(String s,bool dismissible){
showDialog(context: context,
barrierDismissible: dismissible,
builder: (BuildContext context) {
return new LoadingDialog( //调用对话框
text: s==""?'正在获取详情...':s,
);
}
);
}
Widget appbar(String title,List actions){
return AppBar(title: Text(title),
centerTitle: true,
leading: GestureDetector(
child: Image.asset("images/back.png",fit: BoxFit.contain,),
onTap: (){
dispose();
},
),
actions: actions,
);
}
void showToast(String msg){
Fluttertoast.showToast(msg: msg);
}
}
dialoghttps://www.jianshu.com/p/4bbbb5aa855d
class LoadingDialog extends Dialog {
String text;
LoadingDialog({Key key, @required this.text}) : super(key: key);
@override
Widget build(BuildContext context) {
return new Material( //创建透明层
type: MaterialType.transparency, //透明类型
child: new Center( //保证控件居中效果
child: new SizedBox(
width: 120.0,
height: 120.0,
child: new Container(
decoration: ShapeDecoration(
color: Color(0xffffffff),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0),
),
),
),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
new CircularProgressIndicator(),
new Padding(
padding: const EdgeInsets.only(
top: 20.0,
),
child: new Text(
text,
style: new TextStyle(fontSize: 12.0),
),
),
],
),
),
),
),
);
}
}