Hibok
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

71 wiersze
1.8 KiB

  1. /*
  2. * 自定义等待加载提示框
  3. * Created by ZhangJun on 2018-11-29
  4. */
  5. import 'package:flutter/material.dart';
  6. import 'package:chat/utils/my_dialog.dart' as myDialog;
  7. class LoadingManage {
  8. //私有构造函数
  9. LoadingManage._internal();
  10. //保存单例
  11. static LoadingManage _singleton = new LoadingManage._internal();
  12. //工厂构造函数
  13. factory LoadingManage() => _singleton;
  14. static BuildContext context;
  15. showLoading() {
  16. myDialog.showDialog(
  17. context: context,
  18. barrierDismissible: true,
  19. builder: (BuildContext context) {
  20. return LoadingDialog();
  21. });
  22. }
  23. closeLoading() {
  24. Navigator.of(context).pop();
  25. }
  26. }
  27. class LoadingDialog extends Dialog {
  28. final String text;
  29. LoadingDialog({Key key, this.text}) : super(key: key);
  30. @override
  31. Widget build(BuildContext context) {
  32. return new Material(
  33. type: MaterialType.transparency,
  34. child: new Center(
  35. child: new SizedBox(
  36. width: 120.0,
  37. height: 120.0,
  38. child: new Container(
  39. decoration: ShapeDecoration(
  40. color: Colors.black.withOpacity(0.5),
  41. shape: RoundedRectangleBorder(
  42. borderRadius: BorderRadius.all(
  43. Radius.circular(8.0),
  44. ),
  45. ),
  46. ),
  47. child: new Column(
  48. mainAxisAlignment: MainAxisAlignment.center,
  49. crossAxisAlignment: CrossAxisAlignment.center,
  50. children: <Widget>[
  51. new CircularProgressIndicator(
  52. valueColor:
  53. AlwaysStoppedAnimation(Colors.white)),
  54. ],
  55. ),
  56. ),
  57. ),
  58. ),
  59. );
  60. }
  61. }