【问题标题】:Scrolling not working with SingleChildScrollView滚动不适用于 SingleChildScrollView
【发布时间】:2021-05-07 20:36:55
【问题描述】:

我想在使用 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 的布局上滚动,我是否必须使用不同的命令?

【问题讨论】:

    标签: flutter dart flutter-widget flutterdriver


    【解决方案1】:

    如果有人偶然发现这一点,使用新的 integration_test 包即可:

    await tester.scrollUntilVisible(myFinder, 20,
              scrollable: find.descendant(of: find.byType(SingleChildScrollView), matching: find.byType(Scrollable)));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-13
      • 2020-03-25
      • 1970-01-01
      • 2022-07-12
      • 2021-10-28
      相关资源
      最近更新 更多