transformer_page_view 0.1.4

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

Build Status PRs Welcome pub package

transformer_page_view

PageTransformer for flutter

Very simple to use

import 'package:transformer_page_view/transformer_page_view.dart';

...

new TransformerPageView(
loop: true,
transformer: new AccordionTransformer(),
itemBuilder: (BuildContext context, int index) {
  return new Container(
    color: list[index%list.length],
    child: new Center(
      child: new Text("$index",style: new TextStyle(fontSize: 80.0,color: Colors.white),),
    ),
  );
},
itemCount: 3)

Almost the same as PageView.builder, simplely specify a transformer to TransformerPageView, which is a sub class of PageTransformer

Show cases

Parallax

Welcome view

Basic

AccordionTransformer

See code here

ThreeDTransformer

See code here

ScaleAndFadeTransformer

See code here

ZoomInPageTransformer

See code here

ZoomOutPageTransformer

See code here

DepthPageTransformer

See code here

Getting Started

Installation

Add


transformer_page_view:

to your pubspec.yaml ,and run

flutter packages get 

in your project's root directory.

Basic Usage

ParameterDefaultDescription
scrollDirectionAxis.horizontalIf Axis.horizontal, the scroll view's children are arranged horizontally in a row instead of vertically in a column.
loopfalseSet to true to enable continuous loop mode.
indexnoneIndex number of initial slide. if not set , it is controlled by the widget itself,otherwise, it is controlled by another widget, which is returned by itemBuilder
onPageChangedvoid onPageChanged(int index)Called with the new index when the user swiped
durationnew Duration(milliseconds:300)The milliseconds of every transaction animation costs
transformernoneThe most important property of this widget, it returns a transformed widget that based on the widget parameter. If the value is null, a itemBuilder must be specified
itemCountnoneNumber of the total items
itemBuildernoneA function that returns a widget based on index,if it's null,a transformer must be specified

Build-in Parallax

We provide 3 build-in parallaxes, which handle color、image and container

ParallaxColor

ParallaxColor handles the color transform, which controls the color transform from one to another.

ParallaxImage

ParallaxImage handles the image, which speed is slower than the PageView

ParallaxContainer

ParallaxContainer handles the text or other staff, which speed is faster than the PageView

3 build-in parallaxes are all used in subclass of PageTransform,group these parallaxes together, we can create very cool things.

Inspired by page-transformer, and we have an easier way to create this.

See code here

Custom animation

[0.1.4] - [2018.10.19]

* Fix display items when itemCount changes

[0.1.3] - [2018.10.18]

* Fix zero item count

[0.1.1] - [2018.10.10]

* Fix next/previous index in none loop mode.

[0.1.0] - [2018.10.08]

* Implement `TransformerPageController`

[0.0.8] - [2018.09.20]

* Ignore not valid event

[0.0.7] - [2018.09.20]

* Fix bugs

[0.0.6] - [2018.09.20]

* Fix bugs

[0.0.5] - [2018.09.19]

* Fix bugs

[0.0.4] - [2018.09.19]

* Fix bugs

[0.0.2] - [2018.08.30]

* Update readme

[0.0.1] - [2018.08.30]

* Basic animation

example/lib/main.dart

import 'package:example/buildin_transformers.dart';
import 'package:example/images.dart';
import 'package:example/welcome.dart';
import 'package:example/zero.dart';
import 'package:flutter/material.dart';

import 'package:transformer_page_view/transformer_page_view.dart';

import 'package:flutter/cupertino.dart';
import 'dart:math' as Math;
// 1111111 !!!!!!

void main() => runApp(new MyApp());
List<Color> list = [Colors.yellow, Colors.green, Colors.blue];

List<String> images = [
  "assets/Hepburn2.jpg",
  "assets/Hepburn5.jpg",
  "assets/Hepburn4.jpg",
];

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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> {
  IndexController _controller;
  List<String> _types = [
    "AccordionTransformer",
    "ThreeDTransformer",
    "ScaleAndFadeTransformer",
    "ZoomInPageTransformer",
    "ZoomOutPageTransformer",
    "DeepthPageTransformer"
  ];

  String _type;
  FixedExtentScrollController controller;
  int _index = 0;
  double _viewportFraction = 1.0;

  @override
  void initState() {
    _controller = new IndexController();
    _type = "AccordionTransformer";
    controller = new FixedExtentScrollController();
    super.initState();
  }

  PageTransformer getTransformer() {
    switch (_type) {
      case 'AccordionTransformer':
        return new AccordionTransformer();
      case 'ThreeDTransformer':
        return new ThreeDTransformer();
      case 'ScaleAndFadeTransformer':
        return new ScaleAndFadeTransformer();
      case 'ZoomInPageTransformer':
        return new ZoomInPageTransformer();
      case 'ZoomOutPageTransformer':
        return new ZoomOutPageTransformer();
      case 'DeepthPageTransformer':
        return new DeepthPageTransformer();
    }

    throw new Exception("Not a type");
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Column(
        children: <Widget>[
          new Wrap(
            children: <Widget>[
              new RaisedButton(
                onPressed: () {
                  _controller.move(new Math.Random().nextInt(5));
                },
                color: Colors.blue,
                child: new Text("Random"),
              ),
              new RaisedButton(
                onPressed: () {
                  Navigator.of(context)
                      .push(new MaterialPageRoute(builder: (b) {
                    return new Scaffold(
                      appBar: new AppBar(
                        title: new Text("images"),
                      ),
                      body: new ImageTest(),
                    );
                  }));
                },
                color: Colors.blue,
                child: new Text("Image"),
              ),
              new RaisedButton(
                onPressed: () {
                  Navigator.of(context)
                      .push(new MaterialPageRoute(builder: (b) {
                    return new Scaffold(
                        appBar: new AppBar(
                          title: new Text("welcome"),
                        ),
                        body: new Welcome(0));
                  }));
                },
                color: Colors.blue,
                child: new Text("Welcome"),
              ),
              new RaisedButton(
                onPressed: () {
                  Navigator.of(context)
                      .push(new MaterialPageRoute(builder: (b) {
                    return new Zero();
                  }));
                },
                color: Colors.blue,
                child: new Text("Zero"),
              ),
            ],
          ),
          new Row(
            children: <Widget>[
              new RaisedButton(
                onPressed: () {
                  _controller.previous();
                },
                color: Colors.blue,
                child: new Text("Preious"),
              ),
              new SizedBox(
                width: 8.0,
              ),
              new RaisedButton(
                onPressed: () {
                  _controller.next();
                },
                color: Colors.blue,
                child: new Text("Next"),
              ),
              new SizedBox(
                width: 8.0,
              ),
              new RaisedButton(
                onPressed: () {
                  showModalBottomSheet(
                      context: context,
                      builder: (_) {
                        return new CupertinoPicker(
                            scrollController: controller,
                            itemExtent: 30.0,
                            onSelectedItemChanged: (int index) {
                              setState(() {
                                controller = new FixedExtentScrollController(
                                    initialItem: index);
                                _type = _types[index];
                                if (_type == 'ScaleAndFadeTransformer') {
                                  _viewportFraction = 0.8;
                                } else {
                                  _viewportFraction = 1.0;
                                }
                              });
                            },
                            children: _types.map((t) => new Text(t)).toList());
                      });
                },
                color: Colors.blue,
                child: new Text("Animation"),
              ),
            ],
          ),
          new Expanded(
              child: new SizedBox(
            child: new TransformerPageView(
                loop: false,
                index: _index,
                viewportFraction: _viewportFraction,
                controller: _controller,
                transformer: getTransformer(),
                onPageChanged: (int index) {
                  setState(() {
                    _index = index;
                  });
                },
                itemBuilder: (BuildContext context, int index) {
                  return new Image.asset(
                    images[index],
                    fit: BoxFit.fill,
                  );
                },
                itemCount: 3),
          ))
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  transformer_page_view: ^0.1.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or 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:transformer_page_view/transformer_page_view.dart';
  
Version Uploaded Documentation Archive
0.1.4 Oct 18, 2018 Go to the documentation of transformer_page_view 0.1.4 Download transformer_page_view 0.1.4 archive
0.1.2 Oct 18, 2018 Go to the documentation of transformer_page_view 0.1.2 Download transformer_page_view 0.1.2 archive
0.1.1 Oct 10, 2018 Go to the documentation of transformer_page_view 0.1.1 Download transformer_page_view 0.1.1 archive
0.1.0 Oct 10, 2018 Go to the documentation of transformer_page_view 0.1.0 Download transformer_page_view 0.1.0 archive
0.0.9 Sep 20, 2018 Go to the documentation of transformer_page_view 0.0.9 Download transformer_page_view 0.0.9 archive
0.0.8 Sep 20, 2018 Go to the documentation of transformer_page_view 0.0.8 Download transformer_page_view 0.0.8 archive
0.0.7 Sep 20, 2018 Go to the documentation of transformer_page_view 0.0.7 Download transformer_page_view 0.0.7 archive
0.0.6 Sep 20, 2018 Go to the documentation of transformer_page_view 0.0.6 Download transformer_page_view 0.0.6 archive
0.0.5 Sep 19, 2018 Go to the documentation of transformer_page_view 0.0.5 Download transformer_page_view 0.0.5 archive
0.0.4 Sep 18, 2018 Go to the documentation of transformer_page_view 0.0.4 Download transformer_page_view 0.0.4 archive

All 12 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
80
Health:
Code health derived from static analysis. [more]
50
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
67
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.6
  • Flutter: 0.11.3

Platforms

Detected platforms: unsure

Error(s) prevent platform classification:

Error(s) in lib/transformer_page_view.dart: The class 'ChangeNotifierMixin' can't be used as a mixin because it extends a class other than Object.

Health issues and suggestions

Fix lib/transformer_page_view.dart. (-25 points)

Analysis of lib/transformer_page_view.dart failed with 1 error:

line 341 col 10: The class 'ChangeNotifierMixin' can't be used as a mixin because it extends a class other than Object.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Error(s) in lib/transformer_page_view.dart: The class 'ChangeNotifierMixin' can't be used as a mixin because it extends a class other than Object.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.50.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_driver
flutter_test