OnBoardingStateController class
A state controller for managing onboarding page navigation.
This class controls the state and navigation within an onboarding sequence.
It uses a PageController
to manage page transitions and provides functions
to navigate between pages, validate transitions, and trigger actions when the
onboarding is completed.
As an InheritedWidget
, OnBoardingStateController
allows child widgets to
access its state and functions through context-based lookups. This makes it
easy to manage onboarding state across multiple widgets.
Attributes:
- pageController: The
PageController
used to manage page transitions. - setPage: A function to set the current page, optionally animating the transition.
- onDone: A callback function triggered when onboarding is completed.
- pages: A list of
OnboardingModel
representing the pages in the sequence. - currentIndex: The index of the current page.
- styles: The styling options for the onboarding sequence, defined by
OnboardingStyles
.
Usage:
The OnBoardingStateController
is typically used within an onboarding screen
to control the state and manage transitions between pages. It provides functions
to navigate through the onboarding sequence and triggers an onDone
callback
when the onboarding is completed.
Methods:
- isLastIndex: Returns
true
if the current page is the last in the sequence. - length: Returns the total number of pages in the sequence.
- next(): Moves to the next page.
- prev(): Moves to the previous page.
- skip(): Skips to the last page in the sequence.
- getPage(): Returns the data for the current page.
_validateOnPageChange(index)
: Validates whether the given page index is within valid bounds.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- ProxyWidget
- InheritedWidget
- OnBoardingStateController
Constructors
-
OnBoardingStateController.new({required void onDone(), required int currentIndex, required dynamic setPage(int, bool), required PageController pageController, required List<
OnboardingModel> pages, required Widget child, required OnboardingStyles styles, Key? key}) -
const
Properties
- child → Widget
-
The widget below this widget in the tree.
finalinherited
- currentIndex → int
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isLastIndex → bool
-
Determines if the current page is the last in the sequence.
no setter
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- length → int
-
Returns the total number of pages in the sequence.
no setter
- onDone → void Function()
-
final
- pageController → PageController
-
final
-
pages
→ List<
OnboardingModel> -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- setPage → dynamic Function(int, bool)
-
final
- styles → OnboardingStyles
-
final
Methods
-
createElement(
) → InheritedElement -
Inflates this configuration to a concrete instance.
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
-
getPage(
) → OnboardingModel - Returns the current page's data.
-
next(
) → void - Moves to the next page in the sequence.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prev(
) → void - Moves to the previous page in the sequence.
-
skip(
) → void - Skips to and done sequence.
-
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
-
updateShouldNotify(
covariant OnBoardingStateController oldWidget) → bool -
Whether the framework should notify widgets that inherit from this widget.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
of(
BuildContext context) → OnBoardingStateController - Returns the current OnBoardingStateController instance from the widget tree.