0

我想在使用 SingleChildScrollView 的页面上使用颤振驱动程序进行滚动。布局看起来像这样

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(),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            );
          },
        ),
      ),
    );

这是我在颤振驱动程序脚本中滚动的方式:

await world.driver.scrollUntilVisible(ProfileSettingFinder.profileScrollView, ProfileSettingFinder.logout, dyScroll: -15000.0, timeout: scrollTimeoout);

页面实际上滚动,但它只滚动一次..直到我搜索的小部件显示出来..据我所知,scrollUntilVisible命令应该继续滚动,直到显示我想要的小部件

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

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正常滚动,直到找到我想要的小部件,使用完全相同的语法..类似

await world.driver.scrollUntilVisible(HomeFinder.homeListView, HomeFinder.proyekTerbaruHeader, dyScroll: -500.0, timeout: temot);

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

4

1 回答 1

1

以防有人偶然发现这一点,使用新的 integration_test 包可以:

await tester.scrollUntilVisible(myFinder, 20,
          scrollable: find.descendant(of: find.byType(SingleChildScrollView), matching: find.byType(Scrollable)));
于 2021-08-17T19:14:57.660 回答