首页 > 解决方案 > 颤动的圆形进度指示器未显示在应用栏中

问题描述

我正在创建一个项目,我需要在 appbar 中显示进度条。代码如下

bool loader_saver=false;
return Scaffold(
  appBar: new AppBar(
    title: new Text("add data"),
    actions: <Widget>[
      loader_saver?
          new CircularProgressIndicator()
      :
      new FlatButton(
          onPressed: () {
            _add_Data();
          },
          child: new Icon(
            Icons.save,
            color: Colors.white,
          ))

    ],
  )

这是onpressed方法

void _add_data(){ 
final _formstate = _form_key.currentState;
if (_formstate.validate()) {
  _form_key.currentState.save();
  setState(() {
    loader_saver=true;
  });
  }
}

标签: dartflutter

解决方案


这将在 appbar 中显示您的 CircularProgressIndicator,根据您的要求进行更改

actions: <Widget>[
new Container(width: 60.0, height: 20.0, color: Colors.lightGreen,
child: new CircularProgressIndicator(),)]

推荐阅读