Flutter:在内容更改时重建窗口小部件

时间:2019-12-22 17:30:53

标签: android flutter flutter-layout

我使用showDialog来显示“请稍候”对话框,但我想在显示时更改“请稍候”文本。

这是我班的样子:

class Dialogs {
  static Future<void> showLoadingDialog(
      BuildContext context, GlobalKey key) async {
    return showDialog<void>(
        context: context,
        barrierDismissible: false,
        builder: (BuildContext context) {
          return new WillPopScope(
              onWillPop: () async => false,
              child: SimpleDialog(
                  key: key,
                  backgroundColor: Colors.black54,
                  children: <Widget>[
                    Center(
                      child: Column(children: [
                        SpinKitPouringHourglass(color: Colors.lightBlueAccent),
                        SizedBox(height: 10),
                        Text(
                          login.loadingText, //I imported another dart file with prefix 'login'
                          style: TextStyle(color: Colors.blueAccent),
                        )
                      ]),
                    )
                  ]));
        });
  }
}

更改login.loadingText变量不会更改显示的窗口小部件,因为我们需要一个setState方法。

如何在Dialogs类中实现setState方法,因此每次更改login.loadingText变量时,它都会重建/显示我编辑过的文本?

如果需要,代码在GitHub上https://github.com/NovySoft/novyNaplo

0 个答案:

没有答案
相关问题