Open shimomiya-k opened 1 year ago
ran into same issue. Would appreciate some solution.
For me it happens only when crossAxisCount is > 1 and im using SliverMasonryGrid.count
I have same issue. does there any solution with crossAxisCount 2?
I am also getting same issue when using two SliverMasonaryGrid in a CustomScrollView. The scroll just shift to top gridview when the top grid view is not visible in viewport. It is like infinite scroll. Here's the code and output video:
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
class MyScrollingWidget extends StatelessWidget {
const MyScrollingWidget({super.key});
@override
Widget build(BuildContext context) {
final heights =
List.generate(100, (index) => 50 + 10 * Random().nextInt(5).toDouble());
return Scaffold(
appBar: AppBar(
title: const Text("Example"),
),
body: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
const SliverToBoxAdapter(
child: Text("First Grid View"),
),
SliverMasonryGrid.count(
childCount: 4,
crossAxisCount: 2,
mainAxisSpacing: 8.0,
crossAxisSpacing: 8.0,
itemBuilder: (context, index) => Container(
height: heights[index],
color: Colors.yellow,
child: Text("Item $index of Grid 1"),
)),
const SliverToBoxAdapter(
child: Text("First Grid View"),
),
SliverMasonryGrid.count(
childCount: 30,
crossAxisCount: 2,
mainAxisSpacing: 8.0,
crossAxisSpacing: 8.0,
itemBuilder: (context, index) => Container(
height: heights[index],
color: Colors.blue,
child: Text("Item $index of Grid 2"),
)),
],
),
);
}
}
I have a similar problem using SliverMasonryGrid
and SliverList
in CustomScrollView
. The SliverList
is placed below the SliverMasonryGrid
, and the scroll position jumps to the SliverMasonryGrid
when I scroll down to SliverList
. I tried to replace SliverList
with a widget wrapped in SliverBoxToAdapter
, but the problem still occurs.
I have same issue.
I am also getting same issue when using two SliverMasonaryGrid in a CustomScrollView. The scroll just shift to top gridview when the top grid view is not visible in viewport. It is like infinite scroll. Here's the code and output video:
import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; class MyScrollingWidget extends StatelessWidget { const MyScrollingWidget({super.key}); @override Widget build(BuildContext context) { final heights = List.generate(100, (index) => 50 + 10 * Random().nextInt(5).toDouble()); return Scaffold( appBar: AppBar( title: const Text("Example"), ), body: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), slivers: [ const SliverToBoxAdapter( child: Text("First Grid View"), ), SliverMasonryGrid.count( childCount: 4, crossAxisCount: 2, mainAxisSpacing: 8.0, crossAxisSpacing: 8.0, itemBuilder: (context, index) => Container( height: heights[index], color: Colors.yellow, child: Text("Item $index of Grid 1"), )), const SliverToBoxAdapter( child: Text("First Grid View"), ), SliverMasonryGrid.count( childCount: 30, crossAxisCount: 2, mainAxisSpacing: 8.0, crossAxisSpacing: 8.0, itemBuilder: (context, index) => Container( height: heights[index], color: Colors.blue, child: Text("Item $index of Grid 2"), )), ], ), ); } }
Screenrecording_20230520_170231.mp4
i have same issue. How to fix it. :(
I ran into this issue a week ago. Do any of you think it has to do with this flutter bug? Apparently, when using multiple SliverGrids in flutter, the grid won't lay out any of its children if the grid is above the viewport. It sounds similar to the issue with SliverMasonryGrid.
Does anyone have a solution?
Does anyone have a solution?
i don't know, but you can try library: https://pub.dev/packages/waterfall_flow
Does anyone have a solution?
i don't know, but you can try library: https://pub.dev/packages/waterfall_flow
This works perfectly. Thank you
Scrolling does not work when two SliverMasonryGrids are placed inside a CustomScrollView.
Is there any solution to this?
https://user-images.githubusercontent.com/78458737/216241146-dbef5c8e-e3c5-4a4d-bb86-6579b3115be4.mov