GlassPageControl class Panels and controls
Page dots on a glass capsule — iOS's UIPageControl on its platter.
count dots, the current one currentDotWidth wide and in the full label colour, the others round and dimmed. Between two pages the two dots trade width and brightness continuously, so the control can follow a swipe.
Either controller drives it — the dots follow the PageView's scroll,
and a tap or a drag animates the view to the page — or, without one,
currentPage does, and the change is reported to onPageChanged for the
caller to pass back. onPageChanged is called in both cases; null with no
controller makes the control a display.
A tap moves one page toward the side tapped, as iOS's does; a drag along the capsule scrubs to the dot under the finger.
Stack(
children: <Widget>[
PageView(controller: pages, children: photos),
Align(
alignment: Alignment.bottomCenter,
child: GlassPageControl(count: photos.length, controller: pages),
),
],
)
Note: one surface. The dots are drawn inside the glass from the controller's position without a build, so turning a page is no capture of its own — what the page view scrolls under the glass is, and that is the honest price of glass over moving content.
A screen reader hears one adjustable control — "Page 2 of 5" by default — and turns the page with increase and decrease. A keyboard turns a focused control's page with the arrow keys; a display takes no focus.
Under TextDirection.rtl it is mirrored: the first page's dot is at the right, a tap toward the left goes on, and so does the left arrow.
See also:
- GlassSegmentedControl, a choice among a few labelled options.
- GlassTabBar, navigation between top-level pages.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- GlassPageControl
Constructors
-
GlassPageControl({required int count, int currentPage = 0, ValueChanged<
int> ? onPageChanged, PageController? controller, double currentDotWidth = 20, Duration duration = const Duration(milliseconds: 300), Curve curve = Curves.easeInOut, GlassFinish? finish, String? semanticLabel, String semanticFormatterCallback(int page, int count)?, FocusNode? focusNode, bool autofocus = false, Key? key}) -
A control of
countdots — at least one.const
Properties
- autofocus → bool
-
Whether the control takes the focus as soon as it is built.
final
- controller → PageController?
-
The page view this control follows and turns. Null makes currentPage
the page.
final
- count → int
-
How many pages there are.
final
- currentDotWidth → double
-
The current dot's width, logical px; the others are kGlassPageDot
round. kGlassPageDot is a control whose current page is told by
brightness alone.
final
- currentPage → int
-
The current page, when there is no controller. With one, the
controller's position is the current page and this is ignored.
final
- curve → Curve
-
The curve of that turn.
final
- duration → Duration
-
How long a tap takes to turn the page — the controller's animation, or
the dots' own without one.
final
- finish → GlassFinish?
-
The optics. Null takes the theme's.
final
- focusNode → FocusNode?
-
The control's focus. Null makes one the control owns.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onPageChanged
→ ValueChanged<
int> ? -
Called with the page a tap, a drag or a screen reader picks — and, with
a controller, with each page the view settles on nearest.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticFormatterCallback → String Function(int page, int count)?
-
How a screen reader says the current page, from 0, of count. Null says
"Page 2 of 5".
final
- semanticLabel → String?
-
What a screen reader says the control is for.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< GlassPageControl> -
Creates the mutable state for this widget at a given location in the tree.
override
-
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.
override
-
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