fromEnum<T extends Enum> static method
A tour whose steps come from an enum: the enum values (in declaration
order) ARE the steps — stepFor maps each value to its HintStep.
The value is compile-time completeness: the switch in stepFor is
exhaustive, so adding or removing an enum value breaks the build and
the tour can never silently drift from the enum. (Dart cannot
enumerate the values of a type parameter — constructors cannot be
generic either — so values is passed explicitly: pass
MyEnum.values, the type is inferred.)
Implementation
static HintTour fromEnum<T extends Enum>({
required String id,
required List<T> values,
required HintStep Function(T value) stepFor,
Duration stepTimeout = const Duration(seconds: 3),
bool disableBackButton = false,
}) {
return HintTour(
id: id,
steps: [for (final value in values) stepFor(value)],
stepTimeout: stepTimeout,
disableBackButton: disableBackButton,
);
}