Skip to content

How to add PageView in sliver #104

@Ankooo12

Description

@Ankooo12

Here is my code, and it's working properly. ProfileReelsSection() is implemented as a SliverGrid in this

 SliverStickyHeader.builder(
      builder: (context, state) => Container(
        height: 50.0,
        color: cBgColor(context),
        child: Column(
          children: [
            Container(
              height: 1,
              color: cGreyLight1(context),
            ),
            Spacer(),
            Padding(
              padding: EdgeInsets.symmetric(horizontal: 40),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  _icon(imageName: MyImages.reelsCircles),
                  _icon(imageName: MyImages.market),
                ],
              ),
            ),
            Spacer(),
          ],
        ),
      ),
      sticky: true,
      sliver: ProfileReelsSection(),
    ); 

When I use ProfileReelsSection() implemented as a GridView.builder(), it is not working and I receive the error: 'Null check operator used on a null value'.

SliverToBoxAdapter(
     child: Expanded(
      child: PageView(
         children: [
           ProfileReelsSection(),
          ProfileReelsSection(),
         ],
       ),
     ),
   ),

If I use SizedBox with a fixed height, it works without any error, but the size is fixed.

   SliverToBoxAdapter(
        child: SizedBox(
          height: 300, // Set a fixed height for the PageView
          child: PageView(
            children: [
              ProfileReelsSection(),
              ProfileReelsSection(),
            ],
          ),
        ),
      )

Please help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions