From 6982b9c4a0596f0b3db1d907b3e3787c8172e244 Mon Sep 17 00:00:00 2001 From: Stefan Schaller Date: Fri, 8 Mar 2024 09:37:54 +0100 Subject: [PATCH] make snappoints optional --- example/lib/main.dart | 2 +- lib/scrollable_bottom_sheet.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index e1055ab..24d6dcf 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -25,7 +25,7 @@ class MainApp extends StatelessWidget { Align( alignment: Alignment.bottomCenter, child: ScrollableBottomSheet( - snapPoints: [maxHeight / 2], + snapPositions: [maxHeight / 2], initialPosition: maxHeight / 2, onSizeChanged: (tween,height) { print(tween); diff --git a/lib/scrollable_bottom_sheet.dart b/lib/scrollable_bottom_sheet.dart index 3120861..2b26018 100644 --- a/lib/scrollable_bottom_sheet.dart +++ b/lib/scrollable_bottom_sheet.dart @@ -11,7 +11,7 @@ typedef ScrollableBottomSheetBuilder = Widget Function( class ScrollableBottomSheet extends StatefulWidget { final double maxHeight; final double minHeight; - final List snapPoints; + final List snapPositions; final void Function(double animation, double height)? onSizeChanged; final ScrollableBottomSheetBuilder builder; final Duration animationDuration; @@ -31,7 +31,7 @@ class ScrollableBottomSheet extends StatefulWidget { required this.maxHeight, required this.minHeight, required this.builder, - this.snapPoints = const [], + this.snapPositions = const [], this.canDrag = true, this.animationDuration = const Duration(milliseconds: 350), this.onSizeChanged, @@ -207,7 +207,7 @@ class ScrollableBottomSheetState extends State with Singl } double _findNearestRelativeSnapPoint({required double target}) { - final snapValues = widget.snapPoints.map(_pixelToValue).toList(); + final snapValues = widget.snapPositions.map(_pixelToValue).toList(); return _findClosestPosition( positions: [0, ...snapValues, 1], target: target,