Coder Social home page Coder Social logo

douglasiacovelli / page_view_dot_indicator Goto Github PK

View Code? Open in Web Editor NEW
13.0 1.0 11.0 116 KB

A simple and animated page view indicator in the form of dots, which you can customise color, size, space and duration.

Home Page: https://pub.dev/packages/page_view_dot_indicator

License: MIT License

Kotlin 0.61% Swift 1.98% Objective-C 0.19% Dart 97.23%
flutter pageview indicator package dart

page_view_dot_indicator's Introduction

Page view dot indicator

pub package

This lib draws a simple dot indicator for page views with a simple API. Right now it is able to draw dots with custom size, colors, spacing and duration. Besides that it also handles overflow by fading the edges if there are more dots than the width of the page allows.

Usage

Simply use this Widget in your page and make sure to use any form of state management to update the currentItem, such as setState.

These are the mandatory parameters:

PageViewDotIndicator(
  currentItem: selectedPage,
  count: pageCount,
  unselectedColor: Colors.black26,
  selectedColor: Colors.blue,
)

But you can also customize it using other parameters, such as:

PageViewDotIndicator(
  currentItem: selectedPage,
  count: pageCount,
  unselectedColor: Colors.black26,
  selectedColor: Colors.blue,
  size: const Size(12, 12),
  unselectedSize: const Size(8, 8),
  duration: const Duration(milliseconds: 200),
  margin: const EdgeInsets.symmetric(horizontal: 8),
  padding: EdgeInsets.zero,
  alignment: Alignment.centerLeft,
  fadeEdges: false,
  boxShape: BoxShape.square, //defaults to circle
  borderRadius: BorderRadius.circular(5), //only for rectangle shape
  onItemClicked: (index) { ... }
)

page_view_dot_indicator's People

Contributors

abhakhand avatar berkeenesakt avatar douglasiacovelli avatar ihavenoface5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

page_view_dot_indicator's Issues

Seeing flutter error thrown

Hi, we have been using the library for a while now and has been great. We have been seeing some crashes come back in our crash reporting however. Guessing it is unmounted or hasn't added the scroll controller into the scrollView yet.

Non-fatal Exception: FlutterError
0 ??? 0x0 growable_array.Bad_state_No_element:_ + 353 (growable_array.dart:353)
1 ??? 0x0 _GrowableList.single (dart:core)
2 ??? 0x0 ScrollController.position + 109 (scroll_controller.dart:109)
3 ??? 0x0 _PageViewDotIndicatorState._getOffsetForCurrentPosition + 164 (indicator.dart:164)
4 ??? 0x0 _PageViewDotIndicatorState.scrollToCurrentPosition + 101 (indicator.dart:101)
5 ??? 0x0 _PageViewDotIndicatorState.initState. + 89 (indicator.dart:89)
6 ??? 0x0 SchedulerBinding._invokeFrameCallback + 1146 (binding.dart:1146)
7 ??? 0x0 SchedulerBinding.handleDrawFrame + 1091 (binding.dart:1091)
8 ??? 0x0 SchedulerBinding._handleDrawFrame + 997 (binding.dart:997)

Null check operator used on a null value (_maxScrollExtent is null)

Hi, I'm facing a weird issue. I create a PageViewDotIndocator with currentPage = 0 and length = 12. I get the following stacktrace (see below).
The corresponding code in the PageViewDotIndocator code is:

double get maxScrollExtent => _maxScrollExtent!;

I did a quick investigation but didn't find any clue. Any idea? My enclosing layout probably causes it, but this Null check error should probably not happen...

Null check operator used on a null value

When the exception was thrown, this was the stack: 
#0      ScrollPosition.maxScrollExtent (package:flutter/src/widgets/scroll_position.dart:145:49)
#1      _PageViewDotIndicatorState._getOffsetForCurrentPosition (package:page_view_dot_indicator/src/indicator.dart:172:36)
#2      _PageViewDotIndicatorState.scrollToCurrentPosition (package:page_view_dot_indicator/src/indicator.dart:109:26)
#3      _PageViewDotIndicatorState.didUpdateWidget (package:page_view_dot_indicator/src/indicator.dart:103:7)
#4      StatefulElement.update (package:flutter/src/widgets/framework.dart:5142:55)
#5      Element.updateChild (package:flutter/src/widgets/framework.dart:3660:15)
#6      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4993:16)

Don't use MediaQuery

Hi, this widget has a screen-wide width.
image

It's incorrect, I cannot wrap the PageViewDotIndicator into Container because of it
image

Wanted result:
image

Actual result:
image

You probably should use shrink-wrap / IntrinsicWidth, to set an actual content size, instead of a MediaQuery size.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.