Add an indicator for a progression. You can customize indicators (shape, color, ..)

Overview

dots_indicator

Widget to display dots indicator to show a position (for a PageView for example).

Installation

You just need to add dots_indicator as a dependency in your pubspec.yaml file.

dependencies:
  dots_indicator: ^2.0.0

Example

In these example, pageLength is the total of dots to display and currentIndexPage is the position to hightlight (the active dot).

A simple dots indicator

Simple dots

new DotsIndicator(
  dotsCount: pageLength,
  position: currentIndexPage
)

Custom colors

Custom dots colors

new DotsIndicator(
  dotsCount: pageLength,
  position: currentIndexPage,
  decorator: DotsDecorator(
    color: Colors.black87, // Inactive color
    activeColor: Colors.redAccent,
  ),
)

Custom size

You can change the default size of dots.
So you can choose to have dots for no active positions and a rounded rectangle for active position for example.
By default, the shape of dots is CircleBorder, so to have a rounded rectangle for active, you need to change activeShape

Custom dots size

new DotsIndicator(
  dotsCount: pageLength,
  position: currentIndexPage,
  decorator: DotsDecorator(
    size: const Size.square(9.0),
    activeSize: const Size(18.0, 9.0),
    activeShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
  ),
)

Custom shape

You can change the default shape of dots. By default it's a CircleBorder.
You can change the no active and active dot shape.

Custom dots shape

new DotsIndicator(
  dotsCount: pageLength,
  position: currentIndexPage,
  decorator: DotsDecorator(
    shape: const Border(),
    activeShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
  ),
)

Change the space between dots

By default a dot have a margin of 6 pixels on his left and right. It's EdgeInsets.symmetric(horizontal: 6.0). But if you want you can change it, for example to increase the space between dots or to add top margin.

Custom dots space

new DotsIndicator(
  dotsCount: pageLength,
  position: currentIndexPage,
  decorator: DotsDecorator(
    spacing: const EdgeInsets.all(10.0),
  ),
)

Axis and reverse property

There is two other property, axis and reversed. Axis is to display dots indicator horizontally (default) or vertically. Also, you can set reversed: true to reverse the order of dots. (default: false).

For example, if you want to display the dots indicator vertically, but with the first dots on bottom : Set axis: Axis.vertical and reversed: true. Obviously, you can use reversed with Axis.horizontal.

onTap property

You can add onTap property, to listen when a dot has been pressed. Exemple:

onTap: (position) {
  setState(() => _currentPos = position);
}
Comments
  • Why is 'position' a double?

    Why is 'position' a double?

    To me it makes sense that both 'dotCount' and 'position' should be int ('dotCount' is the number of dots, and 'position' is the index of the current dot). Why is 'position' a double? What does it mean for position to be 1.5?

    opened by guillermin 10
  • Allow a specific color and activeColor for every item

    Allow a specific color and activeColor for every item

    Added two new properties: colors and activeColors. Both properties are lists. If unset, defaults to the original color. I modified this because it was something I needed. If you think this isn't right for the main repo, no problem!

    opened by davystrong 4
  • Dots direction

    Dots direction

    Hey Thanks for the awesome package. This made my job very easy. However the direction property is missing. I would like to use a vertical indicator rather horizontal. Do you have plans to upgrade the plugin anytime soon?

    enhancement 
    opened by ashikdnd 4
  • Support null safety

    Support null safety

    The library 'package:dots_indicator/dots_indicator.dart' is legacy, and should not be imported into a null safe library.
    Try migrating the imported library.
    
    Error: This project cannot run with sound null safety, because one or more project dependencies do not
    support null safety:
    
    - dots_indicator
    
    dependencies:
      dots_indicator: ^1.2.0
    
    opened by md84419 2
  • PageView / PageController integration

    PageView / PageController integration

    Hi! Great library, thanks for writing it.

    I wrote a wrapper to integrate these indicators with flutter's built-in PageController. I'm posting it here in case it's a useful addition. Feel free to assign me a PR if this should be integrated with DotsIndicator, or close this ticket if it's out of scope.

    What this does:

    1. registers itself with PageController.addListener so it receives updates
    2. connects DotsIndicator.onTap to the PageController so taps update the PageView position
    class ListenerDots extends StatefulWidget {
      final PageController pos;
      final int dotsCount;
      const ListenerDots({Key? key, required this.pos, required this.dotsCount})
          : super(key: key);
    
      @override
      State<StatefulWidget> createState() => _ListenerDotsState();
    }
    
    class _ListenerDotsState extends State<ListenerDots> {
      double lastPos = 0;
    
      @override
      void initState() {
        widget.pos.addListener(updatePage);
        super.initState();
      }
    
      /// listen handler
      updatePage() => setState(() {
            lastPos = widget.pos.page ?? 0.0;
          });
    
      @override
      void dispose() {
        widget.pos.removeListener(updatePage);
        super.dispose();
      }
    
      onTap(double offset) {
        widget.pos.animateToPage(
          offset.toInt(),
          duration: const Duration(milliseconds: 200),
          curve: Curves.easeInOut,
        );
      }
    
      @override
      Widget build(BuildContext context) => DotsIndicator(
          dotsCount: widget.dotsCount, position: lastPos, onTap: onTap);
    }
    
    enhancement 
    opened by abe-winter 1
  • Dynamic sized unActive or Active Dots

    Dynamic sized unActive or Active Dots

    Good morning everyone. I want to manage that the points are dynamic that the activated and the not activated, are long according to the number of pages it has, is it possible? I attach a picture

    https://ibb.co/wM7Nysv

    enhancement 
    opened by miguelflores1993 1
  • Question: Change color of inactive dots?

    Question: Change color of inactive dots?

    Hi there ! Just wondering if there is functionality to change the color of the inactive dots. I did not see it explicitly and it's very possible I overlooked something!

    opened by Gene-Dana 1
  • Overflow with flutter web

    Overflow with flutter web

    The plugin is working perfectly for the mobile app (Android / iOS)

    When I try to use this plugin with flutter web it works fine except when I try to resize the window. When I resize the window, more points are added to the dots indicator and an overflow appear on the right.

    Error:

    The relevant error-causing widget was: Row org-dartlang-app:///packages/dots_indicator/src/dots_indicator.dart:61:11 The overflowing RenderFlex has an orientation of Axis.horizontal. The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex.

    Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size. This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.

    opened by fvisticot 1
  • Delayed transition

    Delayed transition

    I have a Pageview widget setup along with dots indicator. When the page changes the "position" of the dot also changes. So the dot transition happens immediately even before the page transition completes. A "delay" property would be great to keep both dot and the page transitions in sync.

    opened by softower 1
  • DotsIndicator center

    DotsIndicator center

    Hi,

    I noticed that ColorLoader is not well centered. Reason is that only the right padding is added in the _ColorLoaderState build function, so dots are shifted left as a result. It can be fixed if padding for dots is set in following order:

    padding: const EdgeInsets.only(left: 4.0, right: 8.0)
    padding: const EdgeInsets.only(right: 8.0)
    padding: const EdgeInsets.only(right: 4.0)
    

    I guess since it is a small fix I post it here..but if you want I can send a pull request too.

    Cheers, Milos

    invalid 
    opened by milosjovac 0
  • When there are too many page numbers.

    When there are too many page numbers.

    dots_indicator 2.0.0 When there are too many page numbers.

    log:

    The following assertion was thrown during layout:
    A RenderFlex overflowed by 144 pixels on the right.
    
    opened by lan2000 2
  •  Failed assertion: line 31 pos 16: 'dotsCount != null && dotsCount > 0': is not true

    Failed assertion: line 31 pos 16: 'dotsCount != null && dotsCount > 0': is not true

    Hi,

    I am getting error as: 'package:dots_indicator/src/dots_indicator.dart': Failed assertion: line 31 pos 16: 'dotsCount != null && dotsCount > 0': is not true.

    In init state part I am getting a data from remote server. Once the data verify I set the loadIndicator true so I can show the page. in area that data verify before setting the page loadIndicator to true in setState I set the pageLength. pageLength is integer and it totals of list of the data that I get from database. Everything works. Even I set the dotsCount = pageLength;

    Any idea why I am keep getting this error?

    My code:

    return Scaffold(
        body: new Form(
          key: _formKey,
          child: Stack(
            children: [
              Column(
                children: [
                  // IMAGE AREA TOP
                  Container(
                    height: 230.0,
                    width: MediaQuery.of(context).size.width - 50.0,
                    child: PageView.builder(
                      scrollDirection: Axis.horizontal,
                      controller: _pageController,
                      onPageChanged: ((_page) {
                        setState(() {
                          int _currentValue = int.parse('$_page');
                          currentIndexPage = _currentValue;
                        });
                      }),
                      itemCount: pageLength,
                      itemBuilder: (context, index) => _creditCard(context, currentIndexPage),
                    ),
                  ),
                  // DOTS INDICTOR AREA
                  Padding(
                    padding: const EdgeInsets.only(top: 16.0),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        DotsIndicator(
                          dotsCount: pageLength,
                          position: double.parse('$currentIndexPage'),
                          decorator: DotsDecorator(
                            color: Colors.black38,
                            activeColor: Colors.red,
                            size: const Size.square(9.0),
                            activeSize: const Size(18.0, 9.0),
                            activeShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
                          ),
                        )
                      ],
                    ),
                  ),
    

    flutter doctor -v:

    [✓] Flutter (Channel stable, 1.22.6, on macOS 11.2.2 20D80 darwin-x64, locale en-GB)
        • Flutter version 1.22.6 at /Users/*********/flutter
        • Framework revision 9b2d32b605 (6 weeks ago), 2021-01-22 14:36:39 -0800
        • Engine revision 2f0af37152
        • Dart version 2.10.5
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
        • Android SDK at /Users/*********/Library/Android/sdk
        • Platform android-30, build-tools 30.0.3
        • ANDROID_HOME = /Users/*********/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 12.4)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.4, Build version 12D4e
        • CocoaPods version 1.10.1
    
    [✓] Android Studio (version 4.1)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin installed
        • Dart plugin version 201.9335
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    
    [✓] IntelliJ IDEA Community Edition (version 2020.3.2)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin installed
        • Dart plugin version 203.6912
    
    [✓] Connected device (1 available)
        • iPhone 11 (mobile) • 92E3**************************************E72 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
    
    
    
    
    
    
    bug help wanted 
    opened by NTMS2017 4
Releases(0.0.4)
Owner
Jean-Charles Moussé
Mobile (Android, iOS, Flutter) and Web (React, JS, PHP) developer. Student at Efreitech
Jean-Charles Moussé
A Simple Popup Shape For Flutter

popup_shapes ?? Popup Shapes for Notifications and tooltips. Shapes TOP LEFT CE

Mitul Vaghasiya 13 Oct 25, 2022
✨ A collection of loading indicators animated with flutter. Heavily Inspired by http://tobiasahlin.com/spinkit.

✨ Flutter Spinkit A collection of loading indicators animated with flutter. Heavily inspired by @tobiasahlin's SpinKit. ?? Installing dependencies:

Jeremiah Ogbomo 2.7k Dec 30, 2022
Flutter Smooth PageView indicators

smooth_page_indicator Customizable animated page indicator with a set of built-in effects. infinite Loop support [new] Scrolling dots effect Effects E

Milad akarie 859 Jan 5, 2023
A collection of loading indicators animated with CSS

SpinKit Simple loading spinners animated with CSS. See demo. SpinKit only uses (transform and opacity) CSS animations to create smooth and easily cust

Tobias Ahlin 19k Dec 26, 2022
Bubbleslider - A flutter package support a slider customize UI with bubble animation

bubble_slider This package support a slider customize UI with bubble animation.

MindInventory 11 Jul 26, 2022
A liquid progress indicator for Flutter

liquid_progress_indicator Liquid progress indicator for Flutter. Features Liquid circular progress indicator. Liquid linear progress indicator. Liquid

null 301 Dec 15, 2022
Page indicator for flutter, with multiple build-in layouts.

flutter_page_indicators Page indicator for flutter, with multiple build-in layouts. NOTE:This project is forked from flutter_page_indicator, because t

OpenFlutter 12 Jun 29, 2022
Flutter percent indicator library

Percent Indicator Circular and Linear percent indicators Features Circle percent indicator Linear percent indicator Toggle animation Custom duration o

Diego Velásquez López 596 Dec 30, 2022
A Flutter PageView Indicator has Worm animation

Worm Indicator A Flutter PageView indicator insprired by worm animation. It can be easily integrated with any Flutter PageView. Pull requests are welc

Phuc Huynh 11 May 3, 2022
A simple custom loading indicator package.

custom_loading_indicator A Flutter package to customise the loading indicators with your organisation's logo. Let's say you're a dentist and your app

Harshad Manglani 3 Aug 10, 2020
A light weight library to easily manage a progress dialog with simple steps whenever you need to do it. You can easily show and hide it.

progress_dialog A light weight package to show progress dialog. As it is a stateful widget, you can change the text shown on the dialog dynamically. T

Mohammad Fayaz 202 Dec 11, 2022
Animated triangles background widget with color gradients

Triangles background Animated triangles background widget with color gradients Getting Started click image to see the video Usage add this line to pub

Marco Bavagnoli 17 Oct 13, 2022
A Flutter package to custom splash screen like change logo icon, logo animation, and splash screen background color.

Custom Splash Screen A Flutter package to custom splash screen: change logo icon, logo animation, and splash screen background color. (Custom from ani

tranhuycong 78 Sep 6, 2022
Sample Flutter Drawing App which allows the user to draw onto the canvas along with color picker and brush thickness slider.

DrawApp Sample Flutter Drawing App which allows the user to draw onto the canvas along with color picker and brush thickness slider. All code free to

Jake Gough 226 Nov 3, 2022
Easily add staggered animations to your ListView, GridView, Column and Row children.

Flutter Staggered Animations Easily add staggered animations to your ListView, GridView, Column and Row children as shown in Material Design guideline

null 1.2k Jan 6, 2023
A collection of Screens and attractive UIs built with Flutter ready to be used in your applications. No external libraries are used. Just download, add to your project and use.

Flutter Screens A collection of Login Screens, Buttons, Loaders and Widgets with attractive UIs, built with Flutter, ready to be used in your applicat

Samarth Agarwal 5k Dec 31, 2022
Custom Layout with interactive add button to impove your UI and UX .

Interactive Add button layout Custom Layout with interactive add button to impove your UI and UX . the package is available here inspired from Oleg Fr

Dokkar Rachid Reda 20 Sep 13, 2021
How to add a notification badge in bottom navigation bar

bottom_navigation_badge / BottomNavigationBadge BottomNavigationBadge is a Flutter class developed by westdabestdb. Getting Started Add this to your p

Görkem Erol 50 May 21, 2022
Fade animation - Add fade animation to your app easily

fade_animation Add fade animation to your app easily using simple_animations pac

Mazouzi Aymene 3 Oct 6, 2022