41 lines
848 B
Dart
41 lines
848 B
Dart
|
import 'package:flutter/material.dart';
|
||
|
import 'package:get/get.dart';
|
||
|
|
||
|
/// Loading工具
|
||
|
class LoadingUtil {
|
||
|
LoadingUtil() {}
|
||
|
init() {}
|
||
|
|
||
|
static Future<void> show({String? status}) async {
|
||
|
return showLoading(status: status ?? 'Loading...');
|
||
|
}
|
||
|
|
||
|
static Future<void> dismiss() async {
|
||
|
return hideLoading();
|
||
|
}
|
||
|
|
||
|
static showLoading({String? status}) {
|
||
|
Get.dialog(
|
||
|
GestureDetector(
|
||
|
child: Container(
|
||
|
color: Colors.black54,
|
||
|
child: const Center(
|
||
|
child: CircularProgressIndicator(
|
||
|
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
onTap: () {
|
||
|
// 点击是否退出模态框
|
||
|
Get.back();
|
||
|
},
|
||
|
),
|
||
|
barrierDismissible: false,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
static hideLoading() {
|
||
|
Get.back();
|
||
|
}
|
||
|
}
|