List 如何使用stream builder和bloc模式更好地构建社交媒体应用程序

List 如何使用stream builder和bloc模式更好地构建社交媒体应用程序,list,flutter,stream,bloc,stream-builder,List,Flutter,Stream,Bloc,Stream Builder,目前,我正在使用直接API调用并将数据映射到列表中,并使用回调函数更改列表属性。 我的API模型是 class UserProfileResponse { int status; String message; Data data; } class Data { UserDetails

目前,我正在使用直接API调用并将数据映射到列表中,并使用回调函数更改列表属性。 我的API模型是

        class UserProfileResponse {
                  int status;
                  String message;
                  Data data; }
                      
        class Data {
              UserDetails userDetails;
              List<Post> posts;
              String followers;
              String following; }

        class Post {
          String id;
          String userId;
          String post;
          String imagepath;
          String location;
          DateTime postDate;
          String likes;
          String status;
          String active;
          String inactive;
          String createdBy;
          String postType;
          String userLiked;
          String isGroup;
          String videoLink;
          String comments;
          String shares;
          String thumbnail; }

  class UserDetails {
      String username;
      String email;
      String id;
      String profilePicture;
      String bio;
      String address;
      String mobile; }
class UserProfileResponse{
智力状态;
字符串消息;
数据;}
类数据{
用户详细信息用户详细信息;
列出员额;
弦乐追随者;
字符串后面;}
班岗{
字符串id;
字符串用户标识;
弦杆;
字符串图像路径;
字符串位置;
日期时间后日期;
弦状;
字符串状态;
字符串活动;
字符串无效;
字符串创建方式;
字符串postType;
用户喜欢的字符串;
字符串组;
字符串视频链接;
字符串注释;
串股;
字符串缩略图;}
类用户详细信息{
字符串用户名;
字符串电子邮件;
字符串id;
字符串轮廓图;
弦生物;
字符串地址;
字符串移动;}
我如何使用bloc模式对like和different进行即时更新虽然它需要API调用,但目前我使用set state和update list,然后调用API请求来进行后端更改,这对于回调来说很麻烦?
是否可以使用API响应流来构建它,并为eg like同时列出数据流,而不是选项,以便我可以在网络中毫不延迟地进行更新?

使用streamprovider可能会帮助您做到这一点,但如果是这样,请确保不要多次调用提供程序,您将对API进行不必要的调用。

使用streamprovider可能会对您有所帮助,但请确保不要多次调用该提供程序。如果是这样,您将对API进行不必要的调用。

您至少应该自己尝试,如果遇到任何问题,请寻求帮助,以确保您至少应该自己尝试,如果您遇到任何问题,请向我们寻求帮助