【发布时间】:2021-03-22 13:52:30
【问题描述】:
目前正在使用直接 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; }
在需要 API 调用时,如何使用 bloc 模式即时更新 like 和 like ,目前我使用 set state 并更新列表,然后调用 API 请求进行后端更改,回调很麻烦? 是否可以使用 API 响应流构建它并同时列出数据流,例如,与选项不同,这样我就可以在网络中无延迟地更新?
【问题讨论】:
-
您至少应该自己尝试一下,如果您遇到任何问题,请在 SO 上寻求帮助,请参阅pub.dev/packages/flutter_bloc
标签: list flutter stream bloc stream-builder