Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 继续从上一页获取null_Flutter_Dart_Dialog - Fatal编程技术网

Flutter 继续从上一页获取null

Flutter 继续从上一页获取null,flutter,dart,dialog,Flutter,Dart,Dialog,我不知道为什么它总是从我的dialog类返回null。我希望当我在弹出对话框中单击save时,我会得到return,但它会返回null ListTile( tileColor: Colors.grey.shade100, onTap: () async { await PopUpDialog() .showSigntature(context, color, strokeWidth, _sign) .then

我不知道为什么它总是从我的dialog类返回null。我希望当我在弹出对话框中单击save时,我会得到
return
,但它会返回null

ListTile(
      tileColor: Colors.grey.shade100,
      onTap: () async {
        await PopUpDialog()
            .showSigntature(context, color, strokeWidth, _sign)
            .then((onValue) {
          print(onValue);  // I get null
        });
      },
      contentPadding: EdgeInsets.symmetric(horizontal: 0.0),
      trailing: Padding(
        padding: EdgeInsets.all(10),
        child: Icon(
          Icons.check,
          color: Colors.green,
        ),
      ),
      title:
          Padding(padding: EdgeInsets.all(10), child: Text("Signature"))),
弹出对话框

Future showSigntature(
      BuildContext context, var color, var strokeWidth, var sign) async {
    await showGeneralDialog(
        context: context,
        barrierDismissible: true,
        barrierLabel:
            MaterialLocalizations.of(context).modalBarrierDismissLabel,
        barrierColor: Colors.black45,
        transitionDuration: const Duration(milliseconds: 200),
        pageBuilder: (BuildContext buildContext, Animation animation,
            Animation secondaryAnimation) {
          return Center(
            child: Padding(
                padding: EdgeInsets.all(20),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    RaisedButton(
                        shape: RoundedRectangleBorder(
                            side: BorderSide(color: const Color(0xFF1BC0C5))),
                        onPressed: () async {
                          Navigator.pop(context, "return");
                        },
                        child: Text(
                          "Save",
                          style: TextStyle(color: const Color(0xFF1BC0C5)),
                        ),
                        color: Colors.white),
                  ],
                )),
          );
        });
  }

您只是忘记返回由
showSigntature
返回的值。给你:

Future showSigntature(
      BuildContext context, var color, var strokeWidth, var sign) async {
    return showGeneralDialog(
        context: context,
        barrierDismissible: true,
        barrierLabel:
            MaterialLocalizations.of(context).modalBarrierDismissLabel,
        barrierColor: Colors.black45,
        transitionDuration: const Duration(milliseconds: 200),
        pageBuilder: (BuildContext buildContext, Animation animation,
            Animation secondaryAnimation) {
          return Center(
            child: Padding(
                padding: EdgeInsets.all(20),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    RaisedButton(
                        shape: RoundedRectangleBorder(
                            side: BorderSide(color: const Color(0xFF1BC0C5))),
                        onPressed: () async {
                          Navigator.pop(context, "return");
                        },
                        child: Text(
                          "Save",
                          style: TextStyle(color: const Color(0xFF1BC0C5)),
                        ),
                        color: Colors.white),
                  ],
                )),
          );
        });
  }