Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add PageView in sliver #104

Open
Ankooo12 opened this issue Dec 27, 2024 · 1 comment
Open

How to add PageView in sliver #104

Ankooo12 opened this issue Dec 27, 2024 · 1 comment

Comments

@Ankooo12
Copy link

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

@IMohamedBassam
Copy link

hey @Ankooo12
faced that issue before solved it by these two
flutter_hooks: ^0.20.5
expandable_page_view: ^1.0.17

just read their documentation and let me know if you need more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants