Skip to content

Commit

Permalink
Expose minFlingVelocity to ModalSheetRoute
Browse files Browse the repository at this point in the history
  • Loading branch information
Bjarte Bore committed Jan 21, 2025
1 parent ea69746 commit b49e51c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modal_bottom_sheet/lib/src/bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ModalBottomSheet extends StatefulWidget {
required this.expanded,
required this.onClosing,
required this.child,
this.minFlingVelocity = _minFlingVelocity,
double? minFlingVelocity,
double? closeProgressThreshold,
@Deprecated('Use preventPopThreshold instead') double? willPopThreshold,
double? preventPopThreshold,
Expand All @@ -54,7 +54,8 @@ class ModalBottomSheet extends StatefulWidget {
}) : preventPopThreshold =
preventPopThreshold ?? willPopThreshold ?? _willPopThreshold,
closeProgressThreshold =
closeProgressThreshold ?? _closeProgressThreshold;
closeProgressThreshold ?? _closeProgressThreshold,
minFlingVelocity = minFlingVelocity ?? _minFlingVelocity;

/// The closeProgressThreshold parameter
/// specifies when the bottom sheet will be dismissed when user drags it.
Expand Down
8 changes: 8 additions & 0 deletions modal_bottom_sheet/lib/src/bottom_sheet_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ class _ModalBottomSheet<T> extends StatefulWidget {
this.animationCurve,
this.scrollPhysics,
this.scrollPhysicsBuilder,
this.minFlingVelocity,
});

final double? minFlingVelocity;
final double? closeProgressThreshold;
final ModalSheetRoute<T> route;
final bool expanded;
Expand Down Expand Up @@ -100,6 +102,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
expanded: widget.route.expanded,
containerBuilder: widget.route.containerBuilder,
animationController: widget.route._animationController!,
minFlingVelocity: widget.minFlingVelocity,
shouldClose: widget.route.popDisposition ==
RoutePopDisposition.doNotPop ||
widget.route._hasScopedWillPopCallback
Expand Down Expand Up @@ -142,6 +145,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
class ModalSheetRoute<T> extends PageRoute<T> {
ModalSheetRoute({
this.closeProgressThreshold,
this.minFlingVelocity,
this.containerBuilder,
required this.builder,
this.scrollController,
Expand All @@ -160,6 +164,7 @@ class ModalSheetRoute<T> extends PageRoute<T> {
}) : duration = duration ?? _bottomSheetDuration;

final double? closeProgressThreshold;
final double? minFlingVelocity;
final WidgetWithChildBuilder? containerBuilder;
final WidgetBuilder builder;
final bool expanded;
Expand Down Expand Up @@ -219,6 +224,7 @@ class ModalSheetRoute<T> extends PageRoute<T> {
context: context,
// removeTop: true,
child: _ModalBottomSheet<T>(
minFlingVelocity: minFlingVelocity,
closeProgressThreshold: closeProgressThreshold,
route: this,
secondAnimationController: secondAnimationController,
Expand Down Expand Up @@ -270,6 +276,7 @@ Future<T?> showCustomModalBottomSheet<T>({
Duration? duration,
RouteSettings? settings,
double? closeProgressThreshold,
double? minFlingVelocity,
}) async {
assert(debugCheckHasMediaQuery(context));
assert(debugCheckHasMaterialLocalizations(context));
Expand All @@ -295,6 +302,7 @@ Future<T?> showCustomModalBottomSheet<T>({
duration: duration,
settings: settings,
closeProgressThreshold: closeProgressThreshold,
minFlingVelocity: minFlingVelocity,
));
return result;
}

0 comments on commit b49e51c

Please sign in to comment.