loading.dart 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_easyloading/flutter_easyloading.dart';
  3. import 'package:get/get.dart';
  4. class Loading {
  5. Loading() {
  6. EasyLoading.instance
  7. ..displayDuration = const Duration(milliseconds: 2000)
  8. ..indicatorType = EasyLoadingIndicatorType.ring
  9. ..loadingStyle = EasyLoadingStyle.custom
  10. ..indicatorSize = 35.0
  11. ..lineWidth = 2
  12. ..radius = 10.0
  13. ..progressColor = Colors.white
  14. ..backgroundColor = Colors.black.withOpacity(0.7)
  15. ..indicatorColor = Colors.white
  16. ..textColor = Colors.white
  17. ..maskColor = Colors.black.withOpacity(0.6)
  18. ..userInteractions = true
  19. ..dismissOnTap = false
  20. ..maskType = EasyLoadingMaskType.custom;
  21. }
  22. static void show({String? text}) {
  23. EasyLoading.instance.userInteractions = false;
  24. EasyLoading.show(status: text ?? 'loading'.tr);
  25. }
  26. static void showError(String error) {
  27. EasyLoading.instance.userInteractions = true;
  28. EasyLoading.showError(error);
  29. }
  30. static void toast(String text, {int duration = 1}) {
  31. EasyLoading.showToast(text, duration: Duration(seconds: duration));
  32. }
  33. static void dismiss() {
  34. EasyLoading.instance.userInteractions = true;
  35. EasyLoading.dismiss();
  36. }
  37. }