flutter_parallax 0.1.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 94

flutter_parallax

A Flutter widget that moves according to a scroll controller.

Pub

Features

  • Can contain any widget.
  • Configurable parallax scroll direction.
  • Customizable parallax delegate.
  • For widgets inside and outside a scroll view (list items and list backgrounds for example).

Screenshot

Getting started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  flutter_parallax: "^0.1.2"

In your library add the following import:

import 'package:flutter_parallax/flutter_parallax.dart';

For help getting started with Flutter, view the online documentation.

Example

new Parallax.inside(
    child: new Image.network('https://flutter.io/images/homepage/header-illustration.png'),
    mainAxisExtent: 150.0,
);

You can find more examples in the Example project.

Constructors

  • The Parallax.inside, that computes the parallax offset from its position in its first Scrollable parent. Useful for list or grid items.
  • The Parallax.outside, that computes the parallax offset from the percentage of the scrollable's container extent. Useful for a list or grid background.
  • The Parallax.custom takes a ParallaxDelegate, which provides the ability to customize additional aspects of the child model. For example, a ParallaxDelegate can control the algorithm used to computes the parallax offset of the child within its parent.

Changelog

Please see the Changelog page to know what's recently changed.

Contributions

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue.
If you fixed a bug or implemented a new feature, please send a pull request.

0.1.2

  • Add Dart 2 support.

0.1.1

  • Remove Flutter SDK constraint

0.1.0

  • Initial Open Source release

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_parallax/flutter_parallax.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'Parallax demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  ScrollController _scrollController;

  @override
  void initState() {
    super.initState();
    _scrollController = new ScrollController();
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(title: new Text(widget.title)),
      body: new Stack(
        children: <Widget>[
          new Parallax.outside(
            controller: _scrollController,
            child: new Column(
              children: <Widget>[
                new Container(
                  color: Colors.red,
                  height: 200.0,
                ),
                new Container(
                  color: Colors.pink,
                  height: 200.0,
                ),
                new Container(
                  color: Colors.lightGreen,
                  height: 200.0,
                ),
                new Container(
                  color: Colors.orange,
                  height: 200.0,
                ),
                new Container(
                  color: Colors.teal,
                  height: 200.0,
                ),
                new Container(
                  color: Colors.purple,
                  height: 200.0,
                ),
                new Container(
                  color: Colors.grey,
                  height: 200.0,
                ),
                new Container(
                  color: Colors.lime,
                  height: 200.0,
                ),
                new Container(
                  color: Colors.indigo,
                  height: 200.0,
                ),
                new Container(
                  color: Colors.yellow,
                  height: 200.0,
                ),
                new Container(
                  color: Colors.green,
                  height: 200.0,
                ),
                new Container(
                  color: Colors.blue,
                  height: 200.0,
                ),
              ],
            ),
          ),
          new ListView.builder(
            controller: _scrollController,
            itemBuilder: buildItem,
            itemCount: 20,
          ),
        ],
      ),
    );
  }

  Widget buildItem(BuildContext context, int index) {
    var mode = index % 4;
    switch (mode) {
      case 0:
        return new Parallax.inside(
          child: new Image.network(
              'https://flutter.io/images/homepage/header-illustration.png'),
          mainAxisExtent: 150.0,
        );
      case 1:
        return new Parallax.inside(
          child: new Image.network(
              'http://t.wallpaperweb.org/wallpaper/nature/3840x1024/9XMedia1280TripleHorizontalMountainsclouds.jpg'),
          mainAxisExtent: 150.0,
          direction: AxisDirection.right,
        );
      case 2:
        return new Parallax.inside(
          child: new Image.network(
              'https://flutter.io/images/homepage/header-illustration.png'),
          mainAxisExtent: 150.0,
          flipDirection: true,
        );
      default:
        return new Parallax.inside(
          child: new Image.network(
              'http://t.wallpaperweb.org/wallpaper/nature/3840x1024/9XMedia1280TripleHorizontalMountainsclouds.jpg'),
          mainAxisExtent: 150.0,
          direction: AxisDirection.left,
        );
    }
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_parallax: ^0.1.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_parallax/flutter_parallax.dart';
  
Version Uploaded Documentation Archive
0.1.2 Jul 21, 2018 Go to the documentation of flutter_parallax 0.1.2 Download flutter_parallax 0.1.2 archive
0.1.1 Apr 20, 2018 Go to the documentation of flutter_parallax 0.1.1 Download flutter_parallax 0.1.1 archive
0.1.0 Mar 15, 2018 Go to the documentation of flutter_parallax 0.1.0 Download flutter_parallax 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
88
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
94
Learn more about scoring.

We analyzed this package on Aug 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.11.8
  • Flutter: 0.5.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.11
meta 1.1.5 1.1.6
sky_engine 0.0.99
typed_data 1.1.5 1.1.6
vector_math 2.0.6 2.0.8
Dev dependencies
flutter_test
test ^0.12.0