diff --git a/CHANGELOG.md b/CHANGELOG.md index 01c5172..e387462 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.6.2 +* **Fixed** [#7](https://github.com/flutterwtf/wtf_sliding_sheet/pull/7) + ## 0.6.1 * **Migrate** to a new repository name diff --git a/README.md b/README.md index 1870f43..a03daac 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Add it to your `pubspec.yaml` file: ```yaml dependencies: - wtf_sliding_sheet: ^0.6.1 + wtf_sliding_sheet: ^0.6.2 ``` Install packages from the command line diff --git a/example/pubspec.lock b/example/pubspec.lock index 2c42ef1..1b26e23 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -214,7 +214,7 @@ packages: path: ".." relative: true source: path - version: "0.6.1" + version: "0.6.2" sdks: dart: ">=2.19.0 <3.0.0" flutter: ">=2.5.0" diff --git a/lib/src/sheet.dart b/lib/src/sheet.dart index 7f2dfed..d71d801 100644 --- a/lib/src/sheet.dart +++ b/lib/src/sheet.dart @@ -11,11 +11,8 @@ import 'specs.dart'; import 'util.dart'; part 'scrolling.dart'; - part 'sheet_controller.dart'; - part 'sheet_dialog.dart'; - part 'sheet_state.dart'; /// Widget for building sheet @@ -610,6 +607,9 @@ class _SlidingSheetState extends State final RenderBox? footer = footerKey.currentContext?.findRenderObject() as RenderBox?; + final previousMaxExtent = + isLaidOut ? (sheetHeight / availableHeight).clamp(0.0, 1.0) : 1.0; + final isChildLaidOut = child?.hasSize == true; final prevChildHeight = childHeight; childHeight = isChildLaidOut ? child!.size.height : 0; @@ -626,7 +626,7 @@ class _SlidingSheetState extends State (childHeight != prevChildHeight || headerHeight != prevHeaderHeight || footerHeight != prevFooterHeight)) { - _updateSnappingsAndExtent(); + _updateSnappingsAndExtent(previousMaxExtent: previousMaxExtent); setState(() {}); } }); @@ -703,7 +703,7 @@ class _SlidingSheetState extends State } } - void _updateSnappingsAndExtent() { + void _updateSnappingsAndExtent({num? previousMaxExtent}) { snappings = snapSpec.snappings.map(_normalizeSnap).toList()..sort(); if (extent != null) { @@ -717,7 +717,12 @@ class _SlidingSheetState extends State ..maxExtent = maxExtent ..minExtent = minExtent; - if (currentExtent > maxExtent) currentExtent = maxExtent; + final isCurrentPreviousMaxExtent = previousMaxExtent != null && + (currentExtent - previousMaxExtent).abs() < 0.01; + + if (currentExtent > maxExtent || isCurrentPreviousMaxExtent) { + currentExtent = maxExtent; + } } } diff --git a/pubspec.yaml b/pubspec.yaml index 7a95ac8..a1a4bf3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: wtf_sliding_sheet description: A widget that can be dragged and scrolled in a single gesture and snapped to a list of extents. -version: 0.6.1 +version: 0.6.2 homepage: https://pub.dev/packages/wtf_sliding_sheet repository: https://github.com/flutterwtf/wtf_sliding_sheet