99 lines
2.5 KiB
Dart
99 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:lottie/lottie.dart';
|
|
|
|
class FunctionUtil {
|
|
static BuildContext? dialogContext;
|
|
|
|
///加载数据动画
|
|
static void loading() {
|
|
EasyLoading.show(
|
|
maskType: EasyLoadingMaskType.black,
|
|
indicator: Column(
|
|
children: [
|
|
SizedBox(
|
|
width: 80,
|
|
height: 80,
|
|
child: Lottie.asset(
|
|
'assets/animation/loading.json',
|
|
repeat: true,
|
|
),
|
|
),
|
|
Container(
|
|
margin: const EdgeInsets.only(top: 10),
|
|
child: const Text(
|
|
"加载中...",
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
//显示中间弹窗
|
|
static void popDialog(BuildContext context, Widget widget) {
|
|
showDialog(
|
|
context: context,
|
|
barrierDismissible: true,
|
|
builder: (BuildContext context) {
|
|
dialogContext = context;
|
|
return widget;
|
|
});
|
|
}
|
|
|
|
//显示中间弹窗 点击空白处 返回键不关闭
|
|
static void popDialog2(BuildContext context, Widget widget) {
|
|
showDialog(
|
|
context: context,
|
|
barrierDismissible: false,
|
|
builder: (BuildContext context) {
|
|
dialogContext = context;
|
|
return WillPopScope(onWillPop: () async => false, child: widget);
|
|
});
|
|
}
|
|
|
|
//显示底部弹窗
|
|
static void bottomSheetDialog(BuildContext context, Widget widget) {
|
|
showModalBottomSheet(
|
|
backgroundColor: const Color(0x00FFFFFF),
|
|
context: context,
|
|
/* isDismissible: false,*/
|
|
isScrollControlled: true,
|
|
builder: (BuildContext context) {
|
|
dialogContext = context;
|
|
return widget;
|
|
},
|
|
);
|
|
}
|
|
|
|
//显示底部弹窗
|
|
static void bottomNoSheetDialog(BuildContext context, Widget widget) {
|
|
showModalBottomSheet(
|
|
backgroundColor: Color(0x00FFFFFF),
|
|
context: context,
|
|
isDismissible: false,
|
|
isScrollControlled: true,
|
|
enableDrag: false,
|
|
builder: (BuildContext context) {
|
|
dialogContext = context;
|
|
return WillPopScope(onWillPop: () async => false, child: widget);
|
|
});
|
|
}
|
|
|
|
//返回上一级
|
|
static void pop() {
|
|
Navigator.pop(dialogContext!);
|
|
}
|
|
|
|
//push到下一级
|
|
static Future push(BuildContext context, Widget widget) {
|
|
return Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => widget,
|
|
),
|
|
);
|
|
}
|
|
}
|