Skip to content

Commit 8ffbcd5

Browse files
committed
🚸 Make grid anchor more precise
1 parent 663dfe4 commit 8ffbcd5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,9 +859,19 @@ class DefaultAssetPickerBuilderDelegate
859859
return LayoutBuilder(
860860
builder: (BuildContext c, BoxConstraints constraints) {
861861
final double itemSize = constraints.maxWidth / gridCount;
862-
// Reduce [permissionLimitedBarHeight] for the final height.
863-
final double height =
864-
constraints.maxHeight - permissionLimitedBarHeight;
862+
// Check whether all rows can be placed at the same time.
863+
final bool onlyOneScreen = row * itemSize <=
864+
constraints.maxHeight -
865+
context.bottomPadding -
866+
topPadding -
867+
permissionLimitedBarHeight;
868+
final double height;
869+
if (onlyOneScreen) {
870+
height = constraints.maxHeight;
871+
} else {
872+
// Reduce [permissionLimitedBarHeight] for the final height.
873+
height = constraints.maxHeight - permissionLimitedBarHeight;
874+
}
865875
// Use [ScrollView.anchor] to determine where is the first place of
866876
// the [SliverGrid]. Each row needs [dividedSpacing] to calculate,
867877
// then minus one times of [itemSpacing] because spacing's count in the

0 commit comments

Comments
 (0)