Skip to content

Commit

Permalink
make snappoints optional
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanschaller committed Mar 8, 2024
1 parent 35292e2 commit 6982b9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions lib/scrollable_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ typedef ScrollableBottomSheetBuilder = Widget Function(
class ScrollableBottomSheet extends StatefulWidget {
final double maxHeight;
final double minHeight;
final List<double> snapPoints;
final List<double> snapPositions;
final void Function(double animation, double height)? onSizeChanged;
final ScrollableBottomSheetBuilder builder;
final Duration animationDuration;
Expand All @@ -31,7 +31,7 @@ class ScrollableBottomSheet extends StatefulWidget {
required this.maxHeight,
required this.minHeight,
required this.builder,
this.snapPoints = const <double>[],
this.snapPositions = const <double>[],
this.canDrag = true,
this.animationDuration = const Duration(milliseconds: 350),
this.onSizeChanged,
Expand Down Expand Up @@ -207,7 +207,7 @@ class ScrollableBottomSheetState extends State<ScrollableBottomSheet> 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,
Expand Down

0 comments on commit 6982b9c

Please sign in to comment.