loading_dialog.dart 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'package:flutter/material.dart';
  2. class LoadingDialog extends Dialog {
  3. String text;
  4. LoadingDialog({Key key, @required this.text}) : super(key: key);
  5. @override
  6. Widget build(BuildContext context) {
  7. return Material( //创建透明层
  8. type: MaterialType.transparency, //透明类型
  9. child: Center( //保证控件居中效果
  10. child: SizedBox(
  11. width: 120.0,
  12. height: 120.0,
  13. child: Container(
  14. decoration: ShapeDecoration(
  15. color: Color(0xffffffff),
  16. shape: RoundedRectangleBorder(
  17. borderRadius: BorderRadius.all(
  18. Radius.circular(8.0),
  19. ),
  20. ),
  21. ),
  22. child: Column(
  23. mainAxisAlignment: MainAxisAlignment.center,
  24. crossAxisAlignment: CrossAxisAlignment.center,
  25. children: <Widget>[
  26. CircularProgressIndicator(),
  27. Padding(
  28. padding: const EdgeInsets.only(
  29. top: 20.0,
  30. ),
  31. child: Text(
  32. text,
  33. style: TextStyle(fontSize: 12.0),
  34. ),
  35. ),
  36. ],
  37. ),
  38. ),
  39. ),
  40. ),
  41. );
  42. }
  43. }