首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >滚动不使用SingleChildScrollView

滚动不使用SingleChildScrollView
EN

Stack Overflow用户
提问于 2021-02-03 15:21:50
回答 1查看 612关注 0票数 0

我想在使用SingleChildScrollView的页面上使用颤振驱动程序进行滚动。布局如下

代码语言:javascript
复制
return Scaffold(
      backgroundColor: PinColorsV2.neutralMin,
      body: NotificationListener<OverscrollIndicatorNotification>(
        onNotification: (overscroll) {
          overscroll.disallowGlow();
          return true;
        },
        child: LayoutBuilder(
          builder: (context, constraints) {
            return SingleChildScrollView(
              key: Key(ProfileSettingKey.profileScrollView),
              child: ConstrainedBox(
                constraints: BoxConstraints(
                  minWidth: constraints.maxWidth,
                  minHeight: constraints.maxHeight,
                ),
                child: IntrinsicHeight(
                  child: Column(
                    mainAxisSize: MainAxisSize.max,
                    children: <Widget>[
                      BusinessCardProfileWidget(),
                      Expanded(
                        child: Padding(
                          padding: EdgeInsets.only(top: 10.0),
                          child: ProfileSettingsWidget(),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            );
          },
        ),
      ),
    );

下面是我如何在颤振驱动程序脚本中滚动:

代码语言:javascript
复制
await world.driver.scrollUntilVisible(ProfileSettingFinder.profileScrollView, ProfileSettingFinder.logout, dyScroll: -15000.0, timeout: scrollTimeoout);

该页面实际上滚动,但它只滚动一次一次一点点。直到我搜索的小部件是displayed..as,我知道scrollUntilVisible命令应该一直滚动,直到我想要的小部件显示出来。

我注意到当布局使用ListView.Builder时,行为是不同的。这在应用程序的不同页面上。

代码语言:javascript
复制
return ListView.builder(
      key: Key(HomeKey.homeListView),
      itemCount: 1,
      itemBuilder: (context, index) {
        return Column(
          children: <Widget>[
            _staticBanner(context, model),
            if (_remoteConfigService.agentDashboardEnabled) ...[
              UIHelper.vertSpace(12),
              AgentDashboardWidget(),
            ],
            if (_remoteConfigService.howToGetCommissionEnabled) ...[
              UIHelper.vertSpace(20),
              HowToGetCommissionWidget(),
            ],
            if (_remoteConfigService.featureToggles.infoForYouSectionEnabled) ...[
              InfoForYouWidget(),
            ],
            if (_remoteConfigService.projectFilterShortcutEnabled) ...[
              UIHelper.vertSpace(24),
              BuildingTypeFilterWidget(),
            ],
            if (_remoteConfigService.userSellingPointEnabled) ...[
              UIHelper.vertSpace(36),
              UserSellingPointWidget(
                onTapCallback: () => _goToBenefitWithPinhomeView(context, model),
              ),
            ],
            if (_remoteConfigService.featuredProjectEnabled) ...[
              UIHelper.vertSpace(28),
              ProjectHorizontalListWidget(
                type: ProjectHorizontalListType.featuredProjects,
              ),
            ],
            if (_remoteConfigService.newProjectEnabled) ...[
              UIHelper.vertSpace(28),
              ProjectHorizontalListWidget(
                type: ProjectHorizontalListType.latestProjects,
                widgetKey: Key(HomeKey.proyekTerbaruHeader)
              ),
            ],
            UIHelper.vertSpace(12),
          ],
        );
      },
    );

我可以正常地在这个ListView上滚动,直到我想要的小部件找到为止,使用完全相同的语法。就像这样

代码语言:javascript
复制
await world.driver.scrollUntilVisible(HomeFinder.homeListView, HomeFinder.proyekTerbaruHeader, dyScroll: -500.0, timeout: temot);

如果我想在使用SingleChildScrollView的布局上滚动,是否必须使用不同的命令?

EN

回答 1

Stack Overflow用户

发布于 2021-08-17 19:14:57

如果有人无意中发现了这一点,那么使用新的integration_test包,这是可行的:

代码语言:javascript
复制
await tester.scrollUntilVisible(myFinder, 20,
          scrollable: find.descendant(of: find.byType(SingleChildScrollView), matching: find.byType(Scrollable)));
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66030472

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档