From 273bbe8eb06838fc00576387f26f9c7fb2b2aacf Mon Sep 17 00:00:00 2001 From: Daichi Fujita <68946713+fujidaiti@users.noreply.github.com> Date: Sun, 25 Feb 2024 00:39:58 +0900 Subject: [PATCH] Migrate to flutter 3.20.0.pre (#57) Migrate to `3.20.0-1.1.pre`. This is necessary because the current SDK used to analyze packages on pub.dev is `3.20.0-1.1.pre`, which has a breaking change in the `PageView` class that is not compatible with the current version of this package (described below). As a result, static analysis errors occur on pub.dev. ## What changes will be made in 3.20? `PageView.controller` will be nullable. ## How to migrate? Make `OverflowPageView` always receive a non-nullable `PageController` in the constructor. --- package/CHANGELOG.md | 4 ++++ package/lib/src/addon/modal.dart | 4 +--- package/lib/src/internal/paging.dart | 28 ++++++++++++++++------------ package/pubspec.yaml | 2 +- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/package/CHANGELOG.md b/package/CHANGELOG.md index 40be4af..8500340 100644 --- a/package/CHANGELOG.md +++ b/package/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.1 Feb 25, 2024 + +- Small refactoring (no functional changes). + ## 1.0.0 Feb 24, 2024 - Dart3 is now required. diff --git a/package/lib/src/addon/modal.dart b/package/lib/src/addon/modal.dart index f9a0041..8563278 100644 --- a/package/lib/src/addon/modal.dart +++ b/package/lib/src/addon/modal.dart @@ -235,9 +235,7 @@ class ModalExprollableScrollPhysics extends ScrollPhysics { /// This physics will delegate its logic to a [BouncingScrollPhysics] /// while the user is overscrolling, so that the *drag down to dismiss* action is available /// on every platform. Otherwise, it delegates to the given [parent]. - const ModalExprollableScrollPhysics({ - ScrollPhysics? parent, - }) : super(parent: parent); + const ModalExprollableScrollPhysics({super.parent}); @override ModalExprollableScrollPhysics applyTo(ScrollPhysics? ancestor) { diff --git a/package/lib/src/internal/paging.dart b/package/lib/src/internal/paging.dart index 212b0dd..65eb896 100644 --- a/package/lib/src/internal/paging.dart +++ b/package/lib/src/internal/paging.dart @@ -1,11 +1,11 @@ -/// Copied and modified from: -/// - https://github.com/flutter/flutter/tree/master/packages/flutter/lib/src/widgets/page_view.dart -/// - https://github.com/flutter/flutter/tree/master/packages/flutter/lib/src/rendering/sliver_fill.dart -/// -/// Changes done: -/// - Replace [SliverFillViewport] with [_SliverFillViewport] in [_PageViewState.build] -/// - In [_RenderSliverFillViewport.performLayout], force the children to always occupy the parent viewport, -/// regardless of [_RenderSliverFillViewport.itemExtent]. +// Copied and modified from: +// - https://github.com/flutter/flutter/tree/master/packages/flutter/lib/src/widgets/page_view.dart +// - https://github.com/flutter/flutter/tree/master/packages/flutter/lib/src/rendering/sliver_fill.dart +// +// Changes done: +// - Replace [SliverFillViewport] with [_SliverFillViewport] in [_PageViewState.build] +// - In [_RenderSliverFillViewport.performLayout], force the children to always occupy the parent viewport, +// regardless of [_RenderSliverFillViewport.itemExtent]. // Copyright 2014 The Flutter Authors. All rights reserved. // @@ -376,7 +376,7 @@ class OverflowPageView extends PageView { super.key, super.scrollDirection, super.reverse, - super.controller, + required PageController controller, super.physics, super.pageSnapping, super.onPageChanged, @@ -390,7 +390,7 @@ class OverflowPageView extends PageView { super.scrollBehavior, super.padEnds, required this.childConstraints, - }) : super.builder(); + }) : super.builder(controller: controller); final BoxConstraints childConstraints; @@ -408,7 +408,9 @@ class _PageViewState extends State { @override void initState() { super.initState(); - _lastReportedPage = widget.controller.initialPage; + // FIXME: Workaround to pass the static analysis on pub.dev + // ignore: unnecessary_non_null_assertion + _lastReportedPage = widget.controller!.initialPage; } AxisDirection _getDirection(BuildContext context) { @@ -469,7 +471,9 @@ class _PageViewState extends State { clipBehavior: widget.clipBehavior, slivers: [ _SliverFillViewport( - viewportFraction: widget.controller.viewportFraction, + // FIXME: Workaround to pass the static analysis on pub.dev + // ignore: unnecessary_non_null_assertion + viewportFraction: widget.controller!.viewportFraction, delegate: widget.childrenDelegate, padEnds: widget.padEnds, childConstraints: widget.childConstraints, diff --git a/package/pubspec.yaml b/package/pubspec.yaml index 8c995be..92303e6 100644 --- a/package/pubspec.yaml +++ b/package/pubspec.yaml @@ -1,6 +1,6 @@ name: exprollable_page_view description: Yet another PageView widget that expands its page while scrolling it. Exprollable is a coined word combining the words expandable and scrollable. -version: 1.0.0 +version: 1.0.1 repository: https://github.com/fujidaiti/exprollable_page_view environment: