diff --git a/.fvm/flutter_sdk b/.fvm/flutter_sdk deleted file mode 120000 index 6f06b69..0000000 --- a/.fvm/flutter_sdk +++ /dev/null @@ -1 +0,0 @@ -/Users/julianbissekkou/fvm/versions/3.16.9 \ No newline at end of file diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json deleted file mode 100644 index 02e7826..0000000 --- a/.fvm/fvm_config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flutterSdkVersion": "3.16.9", - "flavors": {} -} \ No newline at end of file diff --git a/.fvmrc b/.fvmrc new file mode 100644 index 0000000..ee6eaac --- /dev/null +++ b/.fvmrc @@ -0,0 +1,3 @@ +{ + "flutter": "3.24.3" +} diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index f3f0319..34d5765 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -60,8 +60,9 @@ class _HomePageState extends State { ), ], ), - floatingActionButton: - FloatingActionButton(onPressed: _scrollToLastElementOfList, child: const Icon(Icons.arrow_downward_rounded)), + floatingActionButton: FloatingActionButton( + onPressed: _scrollToLastElementOfList, + child: const Icon(Icons.arrow_downward_rounded)), ); } @@ -70,11 +71,14 @@ class _HomePageState extends State { } Future _scrollToLastElementOfList() async { - if (_scrollController == null || _scrollableBSKey.currentState == null) return; + if (_scrollController == null || _scrollableBSKey.currentState == null) { + return; + } unawaited(_scrollableBSKey.currentState!.open()); final maxScrollExtent = _scrollController!.position.maxScrollExtent; - await _scrollController?.animateTo(maxScrollExtent, duration: const Duration(seconds: 1), curve: Curves.bounceIn); + await _scrollController?.animateTo(maxScrollExtent, + duration: const Duration(seconds: 1), curve: Curves.bounceIn); } } diff --git a/example/lib/main.dart b/example/lib/main.dart index 2dae0f7..6858b71 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -27,7 +27,8 @@ class TestHomePage extends StatelessWidget { ), body: ListView.builder( itemBuilder: (context, index) { - return ElevatedButton(onPressed: () {}, child: Text(index.toString())); + return ElevatedButton( + onPressed: () {}, child: Text(index.toString())); }, ), ); diff --git a/example/pubspec.lock b/example/pubspec.lock index 4e68eab..a3d1a13 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -75,6 +75,30 @@ packages: description: flutter source: sdk version: "0.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + url: "https://pub.dev" + source: hosted + version: "10.0.5" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + url: "https://pub.dev" + source: hosted + version: "3.0.5" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lints: dependency: transitive description: @@ -87,26 +111,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.11.1" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.15.0" non_uniform_border: dependency: transitive description: @@ -119,10 +143,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" sky_engine: dependency: transitive description: flutter @@ -188,10 +212,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.2" vector_math: dependency: transitive description: @@ -200,14 +224,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - web: + vm_service: dependency: transitive description: - name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + name: vm_service + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "14.2.5" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" - flutter: ">=1.17.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/lib/scrollable_bottom_sheet.dart b/lib/scrollable_bottom_sheet.dart index 2ba6cb7..d0b4dfb 100644 --- a/lib/scrollable_bottom_sheet.dart +++ b/lib/scrollable_bottom_sheet.dart @@ -68,7 +68,8 @@ class ScrollableBottomSheet extends StatefulWidget { } } -class ScrollableBottomSheetState extends State with SingleTickerProviderStateMixin { +class ScrollableBottomSheetState extends State + with SingleTickerProviderStateMixin { final _scrollController = ScrollController(); late final AnimationController _animationController; var _isScrollingEnabled = false; @@ -79,7 +80,8 @@ class ScrollableBottomSheetState extends State with Singl ScrollHoldController? _hold; - Tween get _sizeTween => Tween(begin: widget.minHeight, end: widget.maxHeight); + Tween get _sizeTween => + Tween(begin: widget.minHeight, end: widget.maxHeight); bool get _isPanelOpen => _animationController.value == 1.0; @@ -94,7 +96,9 @@ class ScrollableBottomSheetState extends State with Singl _animationController = AnimationController( vsync: this, duration: widget.animationDuration, - value: widget.initialPosition == null ? 0.0 : _pixelToValue(widget.initialPosition!), + value: widget.initialPosition == null + ? 0.0 + : _pixelToValue(widget.initialPosition!), )..addListener(_notifyScrollListeners); } @@ -110,7 +114,8 @@ class ScrollableBottomSheetState extends State with Singl super.didUpdateWidget(oldWidget); if (!widget.maintainPositionOnConstraintChange) return; - if (oldWidget.maxHeight == widget.maxHeight && oldWidget.minHeight == widget.minHeight) return; + if (oldWidget.maxHeight == widget.maxHeight && + oldWidget.minHeight == widget.minHeight) return; final previousPositionPixels = Tween( begin: oldWidget.minHeight, @@ -122,7 +127,8 @@ class ScrollableBottomSheetState extends State with Singl @override Widget build(BuildContext context) { - final borderRadius = BorderRadius.vertical(top: Radius.circular(widget.borderRadiusTop)); + final borderRadius = + BorderRadius.vertical(top: Radius.circular(widget.borderRadiusTop)); return GestureListener( canDrag: widget.canDrag, @@ -157,7 +163,8 @@ class ScrollableBottomSheetState extends State with Singl ); }, child: Builder( - builder: (context) => widget.builder(context, _scrollController), + builder: (context) => + widget.builder(context, _scrollController), ), ), ), @@ -177,7 +184,9 @@ class ScrollableBottomSheetState extends State with Singl // _drag might be null if the drag activity ended and called _disposeDrag. assert(_hold == null || _drag == null); _drag?.update(details); - if (_scrollController.hasClients && _scrollController.position.pixels <= 0 && details.primaryDelta! > 0) { + if (_scrollController.hasClients && + _scrollController.position.pixels <= 0 && + details.primaryDelta! > 0) { setState(() => _isScrollingEnabled = false); _handleDragCancel(); if (_scrollController.position.pixels != 0.0) { @@ -189,13 +198,16 @@ class ScrollableBottomSheetState extends State with Singl // only slide the panel if scrolling is not enabled if (!_isScrollingEnabled && !_isScrollingBlocked) { - _animationController.value -= primaryDelta / (widget.maxHeight - widget.minHeight); + _animationController.value -= + primaryDelta / (widget.maxHeight - widget.minHeight); } // if the panel is open and the user hasn't scrolled, we need to determine // whether to enable scrolling if the user swipes up, or disable closing and // begin to close the panel if the user swipes down - if (_isPanelOpen && _scrollController.hasClients && _scrollController.offset <= 0) { + if (_isPanelOpen && + _scrollController.hasClients && + _scrollController.offset <= 0) { final scrollingEnabled = primaryDelta < 0; setState(() => _isScrollingEnabled = scrollingEnabled); @@ -247,9 +259,11 @@ class ScrollableBottomSheetState extends State with Singl } final scrollPixelPerSeconds = details.velocity.pixelsPerSecond.dy; - final flingVelocity = -scrollPixelPerSeconds / (widget.maxHeight - widget.minHeight); + final flingVelocity = + -scrollPixelPerSeconds / (widget.maxHeight - widget.minHeight); - final nearestSnapPoint = _findNearestRelativeSnapPoint(target: _animationController.value); + final nearestSnapPoint = + _findNearestRelativeSnapPoint(target: _animationController.value); if (scrollPixelPerSeconds > widget.completeFlingVelocity) { if (flingVelocity.isNegative) { @@ -313,7 +327,8 @@ class ScrollableBottomSheetState extends State with Singl } Future animateToNearestSnapPoint() { - final newPosition = _findNearestRelativeSnapPoint(target: _animationController.value); + final newPosition = + _findNearestRelativeSnapPoint(target: _animationController.value); return animateTo( pixels: _sizeTween.transform(newPosition), duration: widget.animationDuration, diff --git a/pubspec.lock b/pubspec.lock index b1aef11..9ac42a4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -75,6 +75,30 @@ packages: description: flutter source: sdk version: "0.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + url: "https://pub.dev" + source: hosted + version: "10.0.5" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + url: "https://pub.dev" + source: hosted + version: "3.0.5" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lints: dependency: transitive description: @@ -87,26 +111,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.11.1" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.15.0" non_uniform_border: dependency: "direct main" description: @@ -119,10 +143,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" sky_engine: dependency: transitive description: flutter @@ -181,10 +205,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.2" vector_math: dependency: transitive description: @@ -193,14 +217,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - web: + vm_service: dependency: transitive description: - name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + name: vm_service + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "14.2.5" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" - flutter: ">=1.17.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54"