custom_loading_widget.dart 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import 'package:flutter/material.dart';
  2. /// 自定义Loading的UI展示
  3. class CustomLoadingWidget extends StatelessWidget {
  4. const CustomLoadingWidget({
  5. Key? key,
  6. required this.msg,
  7. }) : super(key: key);
  8. final String msg;
  9. @override
  10. Widget build(BuildContext context) {
  11. return _buildBg(children: [
  12. const CircularProgressIndicator(
  13. strokeWidth: 2.5,
  14. valueColor: AlwaysStoppedAnimation(Colors.white),
  15. ),
  16. Container(
  17. margin: const EdgeInsets.only(top: 15),
  18. child: Text(msg, style: const TextStyle(color: Colors.white,fontSize: 14)),
  19. ),
  20. ]);
  21. }
  22. Widget _buildBg({required List<Widget> children}) {
  23. return Container(
  24. padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 15),
  25. decoration: BoxDecoration(
  26. color: const Color(0xcc000000), //不使用传递的背景色 制定自己的背景颜色
  27. borderRadius: BorderRadius.circular(10),
  28. ),
  29. child: Column(mainAxisSize: MainAxisSize.min, children: children),
  30. );
  31. }
  32. }