ink_page_indicator 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 77

Ink Page Indicator #

A package that offers various page indicators inlcuding a Flutter implementation of the Ink Page Indicator. See below for more examples.

Ink Page Indicator

Installing #

Add it to your pubspec.yaml file:

dependencies:
  ink_page_indicator: ^0.1.2

Install packages from the command line

flutter packages get

Usage #

As of now there are two PageIndicators: InkPageIndicator and LeapingPageIndicator. You can see examples of them below.

Every PageIndicator requires an instance of PageIndicatorController which is a PageController that you should assign to your PageView. This allows the PageIndicator to calculate the page count and handle page animations properly.

PageIndicatorController controller;

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

// Assign to PageView
PageView(
  controller: controller,
  children: children,
),

Ink Page Indicator #

The InkPageIndicator comes with four different styles that you can define using the style parameter:

InkStyle.normal InkStyle.simple InkStyle.transition InkStyle.translate
InkStyle.normal InkStyle.simple InkStyle.translate InkStyle.transition

Example

InkPageIndicator(
  gap: 32,
  padding: 16,
  shape: IndicatorShape.circle(13),
  inactiveColor: Colors.grey.shade500,
  activeColor: Colors.grey.shade700,
  inkColor: Colors.grey.shade400,
  controller: controller,
  style: style,
)

LeapingPageIndicator #

A PageIndicator that jumps between the each of its items.

InkStyle.normal

Example

LeapingPageIndicator(
    controller: controller,
    gap: 32,
    padding: 16,
    leapHeight: 32,
    shape: shape,
    activeShape: activeShape,
    inactiveColor: Colors.grey.shade400,
    activeColor: Colors.grey.shade700,
  ),
)

Shapes #

You can specify different IndicatorShapes for inactive and active indicators and the PageIndicator will interpolate between them as exemplified below.

An InkPageIndicator with different shapes using InkStyle.transition
final shape = IndicatorShape(
  width: 12,
  height: 20,
  borderRadius: BorderRadius.circular(0),
);

final activeShape = IndicatorShape(
  width: 12,
  height: 40,
  borderRadius: BorderRadius.circular(0),
);

InkPageIndicator(
    controller: controller,
    gap: 32,
    padding: 16,
    shape: shape,
    style: InkStyle.transition,
    activeShape: activeShape,
    inactiveColor: Colors.grey.shade400,
    activeColor: Colors.grey.shade700,
  ),
)

Contribution #

If you like this package, consider giving it a star on GitHub and a like on pub.dev.

Changelog #

0.1.1 - 0.1.2 #

  • Bug fixes and performance improvements.

0.1.0 #

  • Initial release

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:ink_page_indicator/ink_page_indicator.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Page Indicators',
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        /* appBar: AppBar(
          title: Text('Page Indicators'),
        ), */
        body: Home(),
      ),
    );
  }
}

class Home extends StatefulWidget {
  Home({Key key}) : super(key: key);

  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  PageIndicatorController controller;

  IndicatorShape shape;
  IndicatorShape activeShape;

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

  List<Widget> _createChildren(int count) {
    final List<Widget> result = [];
    for (var i = 0; i < count; i++) {
      result.add(SizedBox.expand());
    }
    return result;
  }

  Widget buildInkPageIndicator(InkStyle style) {
    return Expanded(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Expanded(
            child: InkPageIndicator(
              gap: 32,
              padding: 16,
              shape: shape,
              activeShape: activeShape,
              inactiveColor: Colors.grey.shade500,
              activeColor: Colors.grey.shade700,
              inkColor: Colors.grey.shade400,
              controller: controller,
              style: style,
            ),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    final children = _createChildren(3);

    shape = IndicatorShape(
      width: 4,
      height: 15,
      borderRadius: BorderRadius.circular(1),
    );

    activeShape = IndicatorShape(
      width: 12,
      height: 20,
      borderRadius: BorderRadius.circular(2),
    );

    return Stack(
      children: <Widget>[
        Column(
          children: <Widget>[
            /* buildInkPageIndicator(InkStyle.normal),
            buildInkPageIndicator(InkStyle.simple),
            buildInkPageIndicator(InkStyle.translate), */
            buildInkPageIndicator(InkStyle.transition),
            Expanded(
              child: GestureDetector(
                onTap: () => controller.animateToPage(
                  controller.page != children.length - 1 ? children.length - 1 : 0,
                  duration: Duration(milliseconds: 800),
                  curve: Curves.ease,
                ),
                child: LeapingPageIndicator(
                  controller: controller,
                  gap: 32,
                  padding: 16,
                  shape: shape,
                  activeShape: activeShape,
                  inactiveColor: Colors.grey.shade400,
                  activeColor: Colors.grey.shade700,
                ),
              ),
            )
          ],
        ),
        PageView(
          controller: controller,
          children: children,
        ),
      ],
    );
  }

  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  ink_page_indicator: ^0.1.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:ink_page_indicator/ink_page_indicator.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
54
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]
77
Learn more about scoring.

We analyzed this package on Apr 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/ink_page_indicator.dart.

Run flutter format to format lib/ink_page_indicator.dart.

Format lib/src/animations/animations.dart.

Run flutter format to format lib/src/animations/animations.dart.

Format lib/src/animations/implicit_animation.dart.

Run flutter format to format lib/src/animations/implicit_animation.dart.

Fix additional 15 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/base/base.dart (Run flutter format to format lib/src/base/base.dart.)
  • lib/src/base/indicator_data.dart (Run flutter format to format lib/src/base/indicator_data.dart.)
  • lib/src/base/indicator_shape.dart (Run flutter format to format lib/src/base/indicator_shape.dart.)
  • lib/src/base/page_indicator.dart (Run flutter format to format lib/src/base/page_indicator.dart.)
  • lib/src/base/page_indicator_painter.dart (Run flutter format to format lib/src/base/page_indicator_painter.dart.)
  • lib/src/indicators.dart (Run flutter format to format lib/src/indicators.dart.)
  • lib/src/ink_page_indicator/ink_page_indicator.dart (Run flutter format to format lib/src/ink_page_indicator/ink_page_indicator.dart.)
  • lib/src/ink_page_indicator/ink_page_indicator_data.dart (Run flutter format to format lib/src/ink_page_indicator/ink_page_indicator_data.dart.)
  • lib/src/ink_page_indicator/ink_page_indicator_painter.dart (Run flutter format to format lib/src/ink_page_indicator/ink_page_indicator_painter.dart.)
  • lib/src/leaping_page_indicator/leaping_page_indicator.dart (Run flutter format to format lib/src/leaping_page_indicator/leaping_page_indicator.dart.)
  • lib/src/leaping_page_indicator/leaping_page_indicator_data.dart (Run flutter format to format lib/src/leaping_page_indicator/leaping_page_indicator_data.dart.)
  • lib/src/leaping_page_indicator/leaping_page_indicator_painter.dart (Run flutter format to format lib/src/leaping_page_indicator/leaping_page_indicator_painter.dart.)
  • lib/src/src.dart (Run flutter format to format lib/src/src.dart.)
  • lib/src/util/pressure_path.dart (Run flutter format to format lib/src/util/pressure_path.dart.)
  • lib/src/util/util.dart (Run flutter format to format lib/src/util/util.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
meta ^1.1.8 1.1.8
Transitive dependencies
collection 1.14.11 1.14.12
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test