YurLoading function
void
YurLoading({
- String? message,
- bool isDismisable = false,
- required LoadingStatus loadingStatus,
- InfoType toastType = InfoType.info,
- EasyLoadingIndicatorType indicatorType = EasyLoadingIndicatorType.chasingDots,
- Color? backgroundColor,
- int duration = 2,
Implementation
void YurLoading({
String? message,
bool isDismisable = false,
required LoadingStatus loadingStatus,
InfoType toastType = InfoType.info,
EasyLoadingIndicatorType indicatorType = EasyLoadingIndicatorType.chasingDots,
Color? backgroundColor,
int duration = 2,
}) {
EasyLoading i = EasyLoading.instance;
i
..displayDuration = Duration(seconds: duration)
..indicatorType = indicatorType
..indicatorSize = 45.0
..radius = 10.0
..backgroundColor = backgroundColor ?? Colors.black.withOpacity(0.5)
..progressColor = Colors.white
..indicatorColor = Colors.white
..textColor = Colors.white
..maskColor = Colors.black.withOpacity(0.5)
..userInteractions = true
..dismissOnTap = isDismisable
..customAnimation
..loadingStyle = EasyLoadingStyle.custom;
EasyLoading.addStatusCallback(
(status) => YurLog(name: "EasyLoading", status.toString()),
);
switch (loadingStatus) {
case LoadingStatus.show:
EasyLoading.show(
status: message ?? "Loading...",
dismissOnTap: isDismisable,
);
break;
case LoadingStatus.error:
i.backgroundColor = backgroundColor ?? Colors.red;
EasyLoading.showError(
message ?? "Terjadi kesalahan...",
dismissOnTap: isDismisable,
);
break;
case LoadingStatus.info:
i.backgroundColor = backgroundColor ?? Colors.blue;
EasyLoading.showInfo(
message ?? "Perhatian",
dismissOnTap: isDismisable,
);
break;
case LoadingStatus.success:
i.backgroundColor = backgroundColor ?? Colors.green;
EasyLoading.showSuccess(
message ?? "Berhasil",
dismissOnTap: isDismisable,
);
break;
case LoadingStatus.dismiss:
EasyLoading.dismiss();
break;
}
}