45 lines
1.4 KiB
Dart
45 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
|
|
class Loading {
|
|
Loading() {
|
|
// 调整loading的配置
|
|
// 预览参考 https://nslogx.github.io/flutter_easyloading/#/
|
|
EasyLoading.instance
|
|
// 只作用提示 不作用与loading
|
|
..displayDuration = const Duration(milliseconds: 2000)
|
|
// loading调整
|
|
..indicatorType = EasyLoadingIndicatorType.ring
|
|
..loadingStyle = EasyLoadingStyle.custom
|
|
..indicatorSize = 35.0
|
|
..lineWidth = 2
|
|
..radius = 10.0
|
|
// 颜色调整
|
|
..progressColor = Colors.white
|
|
..backgroundColor = Colors.black.withOpacity(0.7)
|
|
..indicatorColor = Colors.white
|
|
..textColor = Colors.white
|
|
..maskColor = Colors.black.withOpacity(0.6)
|
|
// 是否在loading是可交互
|
|
..userInteractions = true
|
|
// 是否用户点击取消提示 只作用提示 不作用与loading
|
|
..dismissOnTap = false
|
|
// 遮罩类型
|
|
..maskType = EasyLoadingMaskType.custom;
|
|
}
|
|
|
|
static void show([String? text]) {
|
|
// 应在显示加载时允许用户交互
|
|
EasyLoading.instance.userInteractions = false;
|
|
EasyLoading.show(status: text ?? "Loading...");
|
|
}
|
|
|
|
static void toast(String text) {
|
|
EasyLoading.showToast(text);
|
|
}
|
|
|
|
static void dismiss() {
|
|
EasyLoading.instance.userInteractions = true;
|
|
EasyLoading.dismiss();
|
|
}
|
|
} |