小编Leo*_*hiu的帖子

npm运行脚本流不起作用

我创建了一个react native项目,并希望为我的项目启用流程。

我安装了流槽

npm install --save flow-bin
Run Code Online (Sandbox Code Playgroud)

但是,它返回

missing script: flow 
Run Code Online (Sandbox Code Playgroud)

当我跑步时

npm run-script flow
Run Code Online (Sandbox Code Playgroud)

有人知道吗?谢谢!

npm flowtype react-native

4
推荐指数
1
解决办法
3254
查看次数

如何在 FutureBuilder 中显示对话框

在 Flutter 中,我使用 FutureBuilder 来显示来自 API 的数据。我想在出现错误时弹出一个错误对话框。

但是,当我调用 showDialog() 时,它会抛出错误

setState() or markNeedsBuild() called during build.
Run Code Online (Sandbox Code Playgroud)

这是我的代码

    return FutureBuilder(
      future: xxx,
      builder: (context, snapshot) {
        if (snapshot.hasData) {
          //DO SOMETHING

        } else if (snapshot.hasError) {
          //TODO: Show Error

          showDialog(
              context: context,
              builder: (BuildContext context) {
                return AlertDialog(
                  title: Text("Error"),
                  content: Text("HAHAHA"),
                  actions: <Widget>[
                    FlatButton(
                      child: Text("No"),
                    ),
                    FlatButton(
                        child: Text("Yes")
                    ),
                  ],
                );
              }
          );

          return Container();

        } else {
          //DO SOMETHING
        }
      },
Run Code Online (Sandbox Code Playgroud)

请帮助建议我如何在 FutureBuilder 中显示对话框。

showdialog flutter

2
推荐指数
1
解决办法
4870
查看次数

标签 统计

flowtype ×1

flutter ×1

npm ×1

react-native ×1

showdialog ×1