0

Использую PageView внутри NestedScrollView. Во вкладках PageView использую данные из сети, следовательно размер PageView должен подстраиваться под количество карточек с контентом, но это не получается, потому что PageView должен быть обернут в бокс с фиксированной высотой. Как мне растянуть PageView?

первый экран:

NestedScrollView(
  key: _homeNestedKey,
  headerSliverBuilder: (context, innerBoxIsScrolled) {
    return <Widget>[
      SliverAppBar(
        ...
        bottom: CustomTabBar(
          items: tabItems,
          onChangedIndex: _onTabChanged,
          chosenIndex: _chosenTabIndex,
        ),
      ),
    ];
  },
  body: SmartRefresher(
    ...
    onRefresh: _onRefresh,
    onLoading: _onLoading,
    child: PageView(
      onPageChanged: _onPageChanged,
      controller: _pageController,
      children: const [
        FeedContent(),
        PromotionsContent(),
        ShopContent(),
      ],
    ),
  ),
),

Внутри FeedContent:

ListView(
  shrinkWrap: true,
  physics: const NeverScrollableScrollPhysics(),
  children: [
    ...feed.map((f) => FeedItemCard(feedItem: f)),
    const SizedBox(height: 36),
    if (isLoading) const CustomLoader(),
    const SizedBox(height: 100),
  ],
);

введите сюда описание изображения

1 ответ 1

0

Дело было в SmartRefresher - в него нужно было оборачивать не PageView, а каждую страницу в отдельности.

PageView(
        onPageChanged: _onPageChanged,
        controller: _pageController,
        children: [
          RefresherWrapper(
            onRefresh: () => _onRefresh(_feedRefreshController),
            onLoading: () => _onLoading(_feedRefreshController),
            refreshController: _feedRefreshController,
            child: const FeedContent(),
          ),

          RefresherWrapper(
            onRefresh: () => _onRefresh(_promotionsRefreshController),
            onLoading: () => _onLoading(_promotionsRefreshController),
            refreshController: _promotionsRefreshController,
            child: const PromotionsContent(),
          ),

          RefresherWrapper(
            onRefresh: () => _onRefresh(_shopRefreshController),
            onLoading: () => _onLoading(_shopRefreshController),
            refreshController: _shopRefreshController,
            child: const ShopContent(),
          ),
        ],
      ),

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.