loading.dart 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. return result;
  58. },
  59. child: Stack(
  60. alignment: Alignment.center,
  61. children: <Widget>[
  62. Center(child: child),
  63. Offstage(
  64. offstage: !loading,
  65. child: Container(
  66. padding: EdgeInsets.all(16.0),
  67. child: Column(
  68. mainAxisSize: MainAxisSize.min,
  69. children: <Widget>[
  70. Container(
  71. width: 100,
  72. height: 100,
  73. decoration: BoxDecoration(
  74. borderRadius: BorderRadius.all(Radius.circular(10.0)),
  75. color: Colors.black45,
  76. ),
  77. child: SpinKitFadingCircle(
  78. color: Theme.of(context).accentColor,
  79. ),
  80. ),
  81. ],
  82. )),
  83. )
  84. ],
  85. ),
  86. );
  87. }
  88. }