flutter_page_indicator 0.0.3

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

pub package

flutter_page_indicator

Page indicator for flutter, with multiple build-in layouts.

Show cases

showcases

Installation

Add


flutter_page_indicator:

to your pubspec.yaml ,and run

flutter packages get 

in your project's root directory.

Basic Usage

new PageIndicator(
  layout: PageIndicatorLayout.SLIDE,
  size: 20.0,
  controller: YOUR_PAGE_CONTROLLER,
  space: 5.0,
  count: 4,
)

All build-in layouts

| :------------ |:---------------:|:---------------:| | PageIndicatorLayout.NONE | | From 0.0.1 | | PageIndicatorLayout.SLIDE | | From 0.0.1 | | PageIndicatorLayout.WARM | | From 0.0.1 | | PageIndicatorLayout.COLOR | | From 0.0.1 | | PageIndicatorLayout.SCALE | | From 0.0.1 | | PageIndicatorLayout.DROP | | From 0.0.1 |

[0.0.3]

* Fix bugs
* Support loop mode for layout: PageIndicatorLayout.COLOR & PageIndicatorLayout.COLOR.
* Modify all `PageIndicatorLayout` values to uppercase.

[0.0.2]

* Update readme 

[0.0.1]

* Basic usage
* PageIndicatorLayout.NONE
* PageIndicatorLayout.SLIDE
* PageIndicatorLayout.WARM
* PageIndicatorLayout.COLOR
* PageIndicatorLayout.SCALE
* PageIndicatorLayout.DROP

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:flutter_page_indicator/flutter_page_indicator.dart';

import "package:transformer_page_view/transformer_page_view.dart";

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

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(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or press Run > Flutter Hot Reload in IntelliJ). Notice that the
        // counter didn't reset back to zero; the application is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

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

class RadioGroup extends StatefulWidget {
  final List<String> titles;

  final ValueChanged<int> onIndexChanged;

  const RadioGroup({Key key, this.titles, this.onIndexChanged})
      : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return new _RadioGroupState();
  }
}

class _RadioGroupState extends State<RadioGroup> {
  int _index = 1;

  @override
  Widget build(BuildContext context) {
    List<Widget> list = [];
    for (int i = 0; i < widget.titles.length; ++i) {
      list.add(((String title, int index) {
        return new Row(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            new Radio<int>(
                value: index,
                groupValue: _index,
                onChanged: (int index) {
                  setState(() {
                    _index = index;
                    widget.onIndexChanged(_index);
                  });
                }),
            new Text(title)
          ],
        );
      })(widget.titles[i], i));
    }

    return new Wrap(
      children: list,
    );
  }
}

class _MyHomePageState extends State<MyHomePage> {
  int _index = 1;

  double size = 20.0;
  double activeSize = 30.0;

  PageController controller;

  PageIndicatorLayout layout = PageIndicatorLayout.SLIDE;

  List<PageIndicatorLayout> layouts = PageIndicatorLayout.values;

  bool loop = false;

  @override
  void initState() {
    controller = new PageController();
    super.initState();
  }

  @override
  void didUpdateWidget(MyHomePage oldWidget) {

    super.didUpdateWidget(oldWidget);
  }

  @override
  Widget build(BuildContext context) {
    var children = <Widget>[
      new Container(
        color: Colors.red,
      ),
      new Container(
        color: Colors.green,
      ),
      new Container(
        color: Colors.blueAccent,
      ),
      new Container(
        color: Colors.grey,
      )
    ];
    return new Scaffold(
        appBar: new AppBar(
          title: new Text(widget.title),
        ),
        body: new Column(
          children: <Widget>[
            new Row(
              children: <Widget>[
                new Checkbox(value: loop, onChanged: (bool value){
                  setState(() {
                    if(value){
                      controller = new TransformerPageController(
                          itemCount: 4,
                          loop: true
                      );
                    }else{
                      controller = new PageController(
                        initialPage: 0,

                      );
                    }
                    loop = value;
                  });
                }),
                new Text("loop"),
              ],
            ),
            new RadioGroup(
              titles: layouts.map((s) {
                var str = s.toString();
                return str.substring(str.indexOf(".") + 1);
              }).toList(),
              onIndexChanged: (int index) {
                setState(() {
                  _index = index;
                  layout = layouts[index];

                });
              },
            ),
            new Expanded(
                child: new Stack(
              children: <Widget>[
                loop ? new TransformerPageView.children(
                  children: children,
                  pageController: controller,
                ):
                new PageView(
                  controller: controller,
                  children:children ,
                ),
                new Align(
                  alignment: Alignment.bottomCenter,
                  child: new Padding(
                    padding: new EdgeInsets.only(bottom: 20.0),
                    child: new PageIndicator(
                      layout: layout,
                      size: size,
                      activeSize:activeSize,
                      controller: controller,
                      space: 5.0,
                      count: 4,
                    ),
                  ),
                )
              ],
            ))
          ],
        ));
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_page_indicator: ^0.0.3

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_page_indicator/flutter_page_indicator.dart';
  
Version Uploaded Documentation Archive
0.0.3 Oct 10, 2018 Go to the documentation of flutter_page_indicator 0.0.3 Download flutter_page_indicator 0.0.3 archive
0.0.2 Sep 19, 2018 Go to the documentation of flutter_page_indicator 0.0.2 Download flutter_page_indicator 0.0.2 archive
0.0.1 Sep 18, 2018 Go to the documentation of flutter_page_indicator 0.0.1 Download flutter_page_indicator 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
81
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
85
Learn more about scoring.

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

  • Dart: 2.1.0
  • pana: 0.12.7
  • Flutter: 1.0.0

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

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.

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.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 >=2.0.0-dev.48.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_test