TourController class Tours
Runs a guided tour: which tour is active, which step it is on, and how it ends.
The controller holds no widgets and no BuildContext. It knows a step count, supplied by the TourScope the targets register with, which is what lets a tour span several routes: a step whose target is not mounted yet simply has nothing to point at until it registers.
final TourController tour = TourController(storage: myStorage);
TourScope(
controller: tour,
child: const MyApp(),
);
// Anywhere below the scope:
Tour.of(context).start('onboarding');
- Inheritance
-
- Object
- ChangeNotifier
- TourController
Constructors
- TourController({TourStorage? storage, TourStepCallback? onStepChanged, TourEndCallback? onEnd})
- Creates a tour controller.
Properties
- activeTour → String?
-
The running tour's name, or null when no tour is running.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- index → int
-
The zero-based index of the current step.
no setter
- isFirst → bool
-
Whether the current step is the first one.
no setter
- isLast → bool
-
Whether the current step is the last one.
no setter
- isRunning → bool
-
Whether a tour is running.
no setter
- length → int
-
How many steps the active tour has.
no setter
- onEnd → TourEndCallback?
-
Called once when a tour ends, with the reason.
final
- onStepChanged → TourStepCallback?
-
Called whenever the active step changes, including the first one.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- step → int
-
The human-facing step number, one-based.
0when nothing is running.no setter - storage → TourStorage
-
Where completed tours are recorded.
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
cancel(
) → void - Ends the tour without recording it, so it runs again next time.
-
dispose(
) → void -
Discards any resources used by the object.
inherited
-
finish(
) → void - Ends the tour normally and records it as completed.
-
goTo(
int index) → void -
Jumps straight to
indexof the running tour. -
hasProgress(
String tour) → Future< bool> -
Whether
tourhas a recorded position to resume from. -
next(
) → void - Moves to the next step, or finishes the tour when on the last one.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
previous(
) → void - Moves back one step. A no-op on the first step.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
skip(
) → void - Ends the tour early and records it as completed.
-
start(
String tour, {bool force = false, bool resume = false}) → Future< void> -
Starts
tourat its first step. -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited