api 调用 flutter 后更新 ModalBottomSheet

Update ModalBottomSheet after api call in flutter

我是 flutter 新手,正在开发一个调用 api 的应用程序并从底部显示的服务器获取数据 sheet。在这种情况下,我显示底部 sheet 同时执行 api 调用。 api 调用后我想更新底部 sheet 的内容。我使用了一个数据对象来显示底部的内容sheet。 setstate 没有更新已经显示的 bottomsheet。如何在 api 调用后更新底部 sheet 内容。

我的APi电话

model.getSpotDetails(model.spotList[position], position).then((value) =>
      {
        if(value){

        }
      });

我的屁股sheet代码

showModalBottomSheet<void>(
      context: context,
      elevation: 5,
      backgroundColor: AppTheme.white,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.only(topLeft: Radius.circular(20),topRight: Radius.circular(20)),
      ),
      builder: (BuildContext context) {
        return StatefulBuilder(
          builder: (BuildContext context,setState){
            return Container(
              height: 370,
              child: bottomContent(data),
            );
          },
        );
      },
    );

使用 future builder 然后更新你的底部 sheet