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

Feature Request: Scrollable LayoutGrid with Builder Functionality #94

Open
clragon opened this issue Jul 9, 2023 · 2 comments
Open

Comments

@clragon
Copy link

clragon commented Jul 9, 2023

I am exploring this package as a potential alternative to flutter_staggered_grid_view, which no longer supports scrollable staggered grid views (it supports staggered grids, but these are not buildable or scrollable).

This package allows full control over placing items in rows and columns, which is invaluable for creative layouts. However, I couldn't find any option for using a Builder, which is a critical feature for my use case.

Ideally, a LayoutGrid builder should operate like other builders in Flutter. Instead of receiving a list of children, it would rather have a Widget Function(BuildContext context, int index) parameter to dynamically build its children. Using this approach, the Grid could build children only when they are in the viewport. This also means, the Grid would be scrollable and transform it into a LayoutGridView, based on Flutter's naming convention, where Views are scrollable. This functionality is crucial for larger grids with many children, as building all children at all times can lead to significant performance issues.

The usual practice in Flutter for lists and grids is to first create a Sliver version (a builder without a ScrollView), then provide a version wrapped in a BoxScrollView. For example, a ListView is a SliverList wrapped in a BoxScrollView.

The API might look similar to this:

  • a SliverLayoutGrid widget, which is a Sliver that uses a SliverChildBuilderDelegate to build its children.
  • a LayoutGridView widget which is a BoxScrollView that internally uses a SliverLayoutGrid. It could come with both a children list parameter and a .builder constructor. This would not replace the usual LayoutGrid, which is not scrollable.

Incorporating this functionality may entail a significant refactor, and I'm unsure about its feasibility with the current layout algorithm (since flutter_staggered_grid_view removed StaggeredGridView due to performance issues with its layout algorithm). It also deviates somewhat from a pure CSS grid. However, this enhancement would make the package incredibly versatile.

The key use case for this feature is to create infinite, paginated, quilted/staggered image layouts. Pagination can be added externally as long as a Sliver version with a builder is available. I typically use infinite_scroll_pagination to enable this functionality with any Sliver.

@Velkamhell97
Copy link

I am searchig the same functionality, like the CSS grid or flex system, where the row elements expands to the height of the tallest row element, would be very useful if this package had some similar functionality.

@itsmeemaaario-student
Copy link

I was about to make the same request, it would be very useful, specially for not having to set an specific row number.

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

3 participants