显示项目时水平传送带颤动更改列表不会跳到初始页面,只有第一次才跳到初始页面

时间:2019-03-05 16:50:00

标签: dart flutter flutter-layout

我正在使用StreamBuilder

我更新了列表,但是当另一个请求被调用时它再次构建时,它并没有转到请求的初始页面,它仅在第一次加载时才加载,之后又没有加载,应该重新构建就像流构建器正在观察当前请求一样。

return StreamBuilder(
            stream: bloc.getUserMeetingsResponse,
            builder: (BuildContext context,
                    AsyncSnapshot<ClassMeetingsResponse> snapshot) {
                if (snapshot.hasData) {
                    meetingResponse = snapshot.data;
                    widget.lessons = updatelist(widget.lessons);
                    return Container(
                        child: Column(
                            mainAxisSize: MainAxisSize.max,
                            children: <Widget>[
                                SizedBox(
                                    // you may want to use an aspect ratio here for tablet support
                                    height: Dimension.cardHeightRegular,
                                    child: PageView.builder(
                                    // store this controller in a State to save the carousel scroll position
                                        controller: new PageController(viewportFraction: 0.8,
                                                initialPage: UserUtil.getUserRole(
                                                        AppSharedData().userID) == UserRole.student
                                                        ? 0
                                                        : getDesiredPage(
                                                        widget.lessons, widget.classDetails)),
                                        itemCount: widget.lessons.length,
                                        itemBuilder: (BuildContext context, int itemIndex) {
                                            return HorizontalCarouselClassCell(
                                                    meetingModel: widget.lessons[itemIndex]);
                                        },
                                        onPageChanged: (pageNumber) {
                                            if (pageNumber == widget.lessons.length - 1) {
                                                if (hasPrev) {
                                                    isAddOnList = true;
                                                    bloc.getUserMeetingsRequestData.add(
                                                            MeetingListRequestData(
                                                                    widget.lessons[widget.lessons.length - 1]
                                                                            .startTime, -1));
                                                }
                                                // and user Role not student
                                            } else if (pageNumber == 0 &&
                                                    UserUtil.getUserRole(AppSharedData().userID) !=
                                                            UserRole.student) {
                                                if (hasNext) {
                                                    isAddOnList = false;
                                                    bloc.getUserMeetingsRequestData.add(
                                                            MeetingListRequestData(
                                                                    widget.lessons[0].startTime, 1));
                                                }
                                            }
                                        },
                                        reverse: false,
                                    ),
                                )
                            ],
                        ),
                    );
                }
                else {
                    return Container();
                }
            },
        );

0 个答案:

没有答案