simple_parallax 1.2.0
simple_parallax: ^1.2.0 copied to clipboard
Parallax widgets for Flutter, with a container mode and a per-item mode, vertical or horizontal. Pure Dart, no dependencies, any ImageProvider.
SimpleParallax Versions #
1.2.0 #
Both scroll views move to slivers.
Added #
SimpleParallaxContainer.slivers, which takes the content as a list of slivers instead of a single child. The content then builds as it scrolls, and aSliverAppBaror aSliverGridcan ride over the background. On a long list prefer a fixedspeed:autoSpeedspreads the traveloverscanallows over the whole extent, so the drift becomes imperceptible.- A fifth example screen,
ContainerSliversDemo.
Changed #
SimpleParallaxContainerbuilds aCustomScrollViewrather than aSingleChildScrollView. The default constructor putschildin aSliverToBoxAdapter, which lays it out exactly as before.SimpleParallaxWidgetbuilds aCustomScrollViewover oneSliverListrather than aSingleChildScrollViewover aColumnor aRow, so its blocks build as they come into view. Two consequences, both of themListViewbehaviour: a block is laid out across the full cross axis instead of being centred on it, and a block outside the viewport is not in the tree. Pass a block that must keep a narrower cross extent through anAlignor aCenter.
1.1.1 #
Documentation and example, no library change.
- The example covers all four combinations, two modes by two axes, behind a menu. They share
example/lib/main.dartbecause that is the only file pub.dev renders on the example tab, so the three separate entry points only ever showed one of them there. - The four preview animations are redone in one format, 520x260 at 25 frames a second, and laid out as a grid: modes in rows, axes in columns. 1.1.0 shipped before they were regenerated, so its README sized the vertical pair as portrait.
1.1.0 #
Horizontal parallax.
Added #
SimpleParallaxContainer.scrollDirectionandSimpleParallaxWidget.scrollDirection. The background drifts along the scrolled axis, andoverscansizes it on that axis.SimpleParallaxItemreads the axis from the scrollable it sits in, so it slides sideways in a horizontal list with nothing to pass. Itsheightandwidthdefaults swap accordingly: the scrolled axis falls back to the screen extent, the cross axis to the incoming constraints.SimpleParallaxContainer.width, the horizontal counterpart ofheight.- A horizontal example,
example/lib/main_horizontal.dart, and horizontal previews in the README.
Fixed #
SimpleParallaxContainerignores scroll notifications from a nested scrollable running on the other axis, which used to drag the background along.
1.0.2 #
Add animated previews in to README.md
1.0.1 #
Improve example and comments.
1.0.0 #
Rewrite. Breaking changes, see the migration table below.
Changed #
- The package is no longer a Flutter plugin. The
android,ios,linux,macosandwindowsfolders held nothing but theflutter create --template=pluginscaffold, whose only method was never called from Dart. They are gone, along with theflutter: plugin:declaration andlib/simple_parallax_web.dart. - No dependencies left beyond the Flutter SDK.
providerwas replaced byValueListenableBuilderand byFlow, both from the SDK, andflutter_web_pluginswent with the plugin declaration. - Both widgets now take an
ImageProviderinstead of an asset path, so network images, files and raw bytes work. decalis renamedoverscan, which is what it actually controls.SimpleParallaxItemfinds the enclosingScrollableon its own. It works inside aListView, aCustomScrollViewor any other scroll view, and no longer throws when used outsideSimpleParallaxWidget.SimpleParallaxItem.speedis now a0..1fraction of the available travel, default1.0.autoSpeedderives the speed from the real scroll extent instead of requiring the caller to put aGlobalKeyon their child, which was undocumented and silently did nothing when absent.SimpleParallaxWidgetgainedcontroller,paddingandphysics.
Fixed #
- Scrolling rebuilt the whole subtree, content included, on every frame: the
Consumerwrapped the user's widgets. Container mode now rebuilds only the background transform, behind aRepaintBoundary, and item mode repaints without rebuilding anything at all. - Two
ChangeNotifierinstances were never disposed, one per parallax item and one per parallax widget. _key.currentContext!.findRenderObject()!in a post-frame callback crashed when the item left the tree before the next frame. The measurement now happens at paint time, with no force-unwrap.setStatewas called from a post-frame callback without checkingmounted.- The scroll notification was swallowed by returning
true, so an ancestor listener never saw it. - A non-finite scroll metric could place the background nowhere.
- The background could travel past its overscan and uncover its bottom edge; the offset is clamped.
Removed #
providerandflutter_web_pluginsdependencies.- Dead code:
ScrollNotifier.speedandsetSpeed, never called, and the unused scroll offset on the per-item notifier. - Two lints removed from Dart years ago, still listed in
analysis_options.yaml.
Added #
- A test suite. There was none.
Migration #
| Before | Now |
|---|---|
imagePath: 'assets/a.webp' |
image: AssetImage('assets/a.webp') |
decal: 1.5 |
overscan: 1.5 |
SimpleParallaxItem(speed: 0.3) |
speed is a 0..1 fraction, default 1.0 |
SimpleParallaxItem only inside SimpleParallaxWidget |
works inside any scrollable |
0.1.1 #
- Improved README.md
0.1.0 #
- Add parallax mods container and widget.
- Rename all classes
0.0.2 #
- Add comments
- Update depedencies
0.0.1 #
- Initial release