Indicator class

A custom widget that displays a horizontal list of indicators to denote the current position within a series of pages or elements. Typically used in onboarding screens or carousels.

The Indicator widget highlights the current item with a distinct size and color, differentiating it from other items.

Parameters:

  • itemCount: The total number of indicators to be displayed. This should match the total number of pages or elements.
  • selectedItem: The index of the currently active or selected item. This is zero-based, meaning the first item is represented by 0.
  • activeRadius: The radius of the indicator circle when it is selected or active. Defaults to 4.0.
  • inactiveRadius: The radius of the indicator circle when it is not selected. Defaults to 2.5.
  • activeColor: The color of the active or selected indicator. Defaults to Colors.black.
  • inactiveColor: The color of inactive indicators. Defaults to Colors.grey.
  • spaceBetween: The horizontal space between each indicator. Defaults to 10.0.

Usage example:

Indicator(
  itemCount: 3,
  selectedItem: 1,
)

This will create a row of three indicators with the second indicator marked as active.

Inheritance

Constructors

Indicator({Key? key, required int itemCount, required int selectedItem, double activeRadius = 4, double inactiveRadius = 2.5, Color activeColor = Colors.black, Color inactiveColor = Colors.grey, double spaceBetween = 10})
Usage example:
const

Properties

activeColor Color
  • activeColor: The color of the active or selected indicator. Defaults to Colors.black.
  • final
    activeRadius double
  • activeRadius: The radius of the indicator circle when it is selected or active. Defaults to 4.0.
  • final
    hashCode int
    The hash code for this object.
    no setterinherited
    inactiveColor Color
  • inactiveColor: The color of inactive indicators. Defaults to Colors.grey.
  • final
    inactiveRadius double
  • inactiveRadius: The radius of the indicator circle when it is not selected. Defaults to 2.5.
  • final
    itemCount int
  • itemCount: The total number of indicators to be displayed. This should match the total number of pages or elements.
  • final
    key Key?
    Controls how one widget replaces another widget in the tree.
    finalinherited
    runtimeType Type
    A representation of the runtime type of the object.
    no setterinherited
    selectedItem int
  • selectedItem: The index of the currently active or selected item. This is zero-based, meaning the first item is represented by 0.
  • final
    spaceBetween double
  • spaceBetween: The horizontal space between each indicator. Defaults to 10.0.
  • final

    Methods

    build(BuildContext context) Widget
    Describes the part of the user interface represented by this widget.
    override
    createElement() StatelessElement
    Creates a StatelessElement to manage this widget's location in the tree.
    inherited
    debugDescribeChildren() List<DiagnosticsNode>
    Returns a list of DiagnosticsNode objects describing this node's children.
    inherited
    debugFillProperties(DiagnosticPropertiesBuilder properties) → void
    Add additional properties associated with the node.
    inherited
    noSuchMethod(Invocation invocation) → dynamic
    Invoked when a nonexistent method or property is accessed.
    inherited
    toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
    Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
    inherited
    toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
    A string representation of this object.
    inherited
    toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
    Returns a string representation of this node and its descendants.
    inherited
    toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
    Returns a one-line detailed description of the object.
    inherited
    toStringShort() String
    A short, textual description of this widget.
    inherited

    Operators

    operator ==(Object other) bool
    The equality operator.
    inherited