Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use PageView inside a CustomScrollView

Tags:

flutter

dart

I have a CustomScrollView Contain a :-

1- SliverToBoxAdapter which have tree of widgets

2- SliverList

The problem is happened when i Wrap SliverList with PageView its normal because CustomScrollView only accept Slivers

code snippet

        CustomScrollView(
          slivers: <Widget>[
            SliverToBoxAdapter(child : ),
        PageView(children: <Widget>[SliverList()])]


run result

A RenderViewport expected a child of type RenderSliver but received a child of type RenderRepaintBoundary. RenderObjects expect specific types of children because they coordinate with their children during layout and paint. For example, a RenderSliver cannot be the child of a RenderBox because a RenderSliver does not understand the RenderBox layout protocol.

like image 892
Mohamed Gaber Avatar asked Sep 21 '19 20:09

Mohamed Gaber


1 Answers

I resolved this issue by using NestedScrollView :-

header property have SliverToBoxAdapter it accepts Slivers

body property have PageView it doesn't accept Slivers

like image 156
Mohamed Gaber Avatar answered Sep 22 '22 14:09

Mohamed Gaber