loading.dart 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_spinkit/flutter_spinkit.dart';
  4. class RequestLoadingWidget extends StatelessWidget {
  5. @override
  6. Widget build(BuildContext context) {
  7. return Padding(
  8. padding: const EdgeInsets.symmetric(vertical: 50.0),
  9. child: SpinKitWave(
  10. color: Theme.of(context).accentColor,
  11. ),
  12. );
  13. }
  14. }
  15. Widget FadeingCircleLoading(BuildContext context, {Color backgroundColor, Function callBack}) {
  16. return Positioned(
  17. top: 0,
  18. left: 0,
  19. right: 0,
  20. bottom: 0,
  21. child: callBack != null
  22. ? InkWell(
  23. child: Container(
  24. color: backgroundColor != null ? backgroundColor : Color.fromRGBO(255, 255, 255, 0.5),
  25. width: 100,
  26. height: 150,
  27. child: SpinKitFadingCircle(
  28. size: 100.0,
  29. color: Theme.of(context).accentColor,
  30. ),
  31. ),
  32. onTap: () {
  33. callBack();
  34. },
  35. )
  36. : Container(
  37. color: backgroundColor != null ? backgroundColor : Color.fromRGBO(255, 255, 255, 0.5),
  38. width: 100,
  39. height: 150,
  40. child: SpinKitFadingCircle(
  41. size: 100.0,
  42. color: Theme.of(context).accentColor,
  43. ),
  44. ),
  45. );
  46. }
  47. class LoadingWidget extends StatelessWidget {
  48. bool loading = false;
  49. Widget child;
  50. LoadingWidget({this.loading = false, @required this.child});
  51. @override
  52. Widget build(BuildContext context) {
  53. return WillPopScope(
  54. onWillPop: () async {
  55. bool result = !loading;
  56. if (result) {
  57. }
  58. return result;
  59. },
  60. child: Stack(
  61. alignment: Alignment.center,
  62. children: <Widget>[
  63. Center(child: child),
  64. Offstage(
  65. offstage: !loading,
  66. child: Container(
  67. color: Color(0x80000000),
  68. child: SpinKitFadingCircle(
  69. size: 100.0,
  70. color: Theme.of(context).accentColor,
  71. ),
  72. ),
  73. )
  74. ],
  75. ),
  76. );
  77. }
  78. }