Flutter 自定义loading及使用

Flutter 自定义loading及使用

1.首先写一个公共组件

new Material(
      type: MaterialType.transparency,
      child: new Center(
        child: new SizedBox(
          width: 120.0,
          height: 120.0,
          child: new Container(
            decoration: Shapedecoration(
              color: Color(0xffffffff),
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(
                  Radius.circular(8.0),
                ),
              ),
            ),
            child: new Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                new CircularProgressIndicator(
                    valueColor: new AlwaysstoppedAnimation(Color(0xffAA1F52))),
                new Padding(
                  padding: const EdgeInsets.only(
                    top: 20.0,
                  ),
                  child: new Text(widget.text),
                ),
              ],
            ),
          ),
        ),
      ),
    );

2.封装loading组建

void showLoading(BuildContext context,String text){
  showDialog(
    context: context,
    barrierdismissible: false,
    builder: (BuildContext context) {
      return new Loading(
        text,
      );
    }
  );
}

3.调用loading弹窗

 showLoading(context, "加载中");

效果如下:::

在这里插入图片描述

相关文章

这篇文章主要讲解了“FlutterComponent动画的显和隐怎么实现...
这篇文章主要讲解了“flutter微信聊天输入框功能如何实现”,...
本篇内容介绍了“Flutter之Navigator的高级用法有哪些”的有...
这篇文章主要介绍“Flutter怎么使用Android原生播放器”,在...
Flutter开发的android端如何修改APP名称,logo,版本号,具体...
Flutter路由管理初识路由概念一.路由管理1.1.Route1.2.Mater...