微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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, "加载中");

效果如下:::

在这里插入图片描述

原文地址:https://blog.csdn.net/klousYG/article/details/105846235

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐