loading.dart 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import 'package:flutter/material.dart';
  2. import 'final_widget.dart';
  3. bool loadingStatus = false;
  4. class Loading {
  5. static void start(BuildContext ctx, {String? text}) {
  6. if (loadingStatus) {
  7. return ;
  8. }
  9. loadingStatus = true;
  10. showDialog(context: ctx, builder: (context)
  11. {
  12. return Scaffold(
  13. backgroundColor: Colors.transparent,
  14. body: Center(
  15. child: Column(
  16. mainAxisAlignment: MainAxisAlignment.center,
  17. children: _list(text),
  18. ),
  19. ),
  20. );
  21. });
  22. }
  23. static List<Widget> _list(String? text) {
  24. if (text == null || text.isEmpty) {
  25. return <Widget>[
  26. const CircularProgressIndicator()
  27. ];
  28. }else {
  29. return <Widget>[
  30. const CircularProgressIndicator(),
  31. const SizedBox(
  32. height: 10,
  33. ),
  34. Text(text, style: O2UI.whiteTextStyle,)
  35. ];
  36. }
  37. }
  38. static void complete(BuildContext ctx) {
  39. if (loadingStatus) {
  40. loadingStatus = false;
  41. Navigator.of(ctx, rootNavigator: true).pop();
  42. }
  43. }
  44. }