mobile_skt/lib/util/loading_util.dart

50 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';
import 'package:sk_base_mobile/app_theme.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
class LoadingUtil {
LoadingUtil();
static Future<void> show({String? status}) async {
return showLoading(status: status ?? 'Loading...');
}
static Future<void> dismiss() async {
return hideLoading();
}
static showLoading({String? status}) async {
await showDialog(
context: Get.context!,
barrierColor: AppTheme.barrierColor,
barrierDismissible: false,
builder: (BuildContext context) {
return WillPopScope(
onWillPop: () async => false,
child: GestureDetector(
child: Container(
color: Colors.black54,
child: Center(
child: LoadingAnimationWidget.fourRotatingDots(
color: AppTheme.primaryColor,
size: ScreenAdaper.sp(50),
),
),
),
onTap: () {
// 点击是否退出模态框
// Navigator.of(context).pop();
},
),
);
},
);
}
static hideLoading() {
Navigator.of(Get.context!).pop();
}
}