AlertBox 没有显示颤振

AlertBox is not showing flutter

我有带有图像和一些细节的列表视图,如果没有数据,它应该是 return 带有消息的警告框,但是当我尝试时,警告框没有出现,我正在为此使用 rflutter

如果没有数据,这是我得到的结果

{
  "status": true,
  "Image": []
}

如果json return没有数据,应该弹出警告框

图像列表代码

 Future<String> getImageList(String set_id) async {

        ProgressDialog dialog = CustomDialogs().showLoadingProgressDialog(context);

             var response = await http.post(Urls.ImageList,
                  headers: {
                    "Content-Type": "application/json",
                    "Authorization": "Bearer $token",
                  },
                  body: json.encode({
                    "sets_id": set_id,

                  }));

              if (response.statusCode == 200) {

                dialog.dismissProgressDialog(context);

                try {
                  var resp = response.body;
                  print(resp);
                  if(resp != null)
                    {
                      Map<String, dynamic> value = json.decode(resp);
                      var report = value['Image'];

                      for (int i = 0; i < report.length; i++) {
                        var data = report[i];
                        var SetName = data["Set_Id"]["Set_Name"];

                        Imagelist.add(ImageModel.fromJson(data, SetName , ));
                      }

                      setState(() {
                        array_lenth = Imagelist.length;
                      });
                    }
                  else
                    {
                      Alert(
                        context: context,
                        type: AlertType.error,
                        title: "No Data",
                        desc: "No Avilable Data Found",
                        buttons: [
                          DialogButton(
                            child: Text(
                              "COOL",
                              style: TextStyle(color: Colors.white, fontSize: 20),
                            ),
                            onPressed: () => Navigator.pop(context),
                            width: 120,
                          )
                        ],
                      ).show();
                    }

                } catch (e) {
                  e.toString();
                }
              }
              else {
                print("Error");
              }
          }
      }

您正在检查空值,但您应该检查长度。

你的条件应该如下。

 if(resp.length < 0)