Tutorial<T> class

A controller for managing tutorial state and navigation.

Handles multiple tutorials identified by type T (typically String enums). Works with TutorialOverlay to display step-by-step guides with tooltips.

{@tool snippet}

final tutorial = Tutorial<String>({
  'home': [TutorialStep(child: Text('Welcome!'))],
  'profile': [TutorialStep(child: Text('Set up your profile.'))],
});

{@end-tool}

Inheritance

Constructors

Tutorial.new(Map<T, List<TutorialStep>> tutorials, {NavigatorState? navigator})
Creates a tutorial controller with the given tutorials.

Properties

availableTutorials List<T>
Returns a list of all available tutorial IDs.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
endTutorial(T tutorialId) → void
Ends the tutorial with the given tutorialId.
getCurrentStep(T tutorialId) int
Gets current step index (-1 = not started)
getSteps(T tutorialId) List<TutorialStep>
Gets all steps for a tutorial (empty if not found)
initializeState({List<T>? tutorialIds}) → void
Initializes the state for specified or all tutorials.
isLastStep(T tutorialId) bool
Whether current step is the last one
nextStep({required T tutorialId, String? route, Object? arguments, bool backToPreviousPage = false, BuildContext? context}) → void
Advances to the next step or ends tutorial if last step.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
previousStep({required T tutorialId, String? route, Object? arguments, bool backToPreviousPage = false, BuildContext? context}) → void
Returns to previous step (if not first step)
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
startTutorial(T tutorialId) → void
Starts the tutorial with the given tutorialId.
toString() String
A string representation of this object.
inherited
updateTutorial(Map<T, List<TutorialStep>> newTutorials) → void
Updates the tutorials with a new map of tutorial steps.

Operators

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

Static Methods

provide({required Tutorial tutorial, required Widget child}) Widget
Wraps the widget tree with a ChangeNotifierProvider to provide the tutorial controller.