replaceKind<Kind extends WildnessBase> method
Replace current kind in the wildnessThemeData.
If the kind exist already in wildness components and is Type or Covariant
of the provide Kind
then replace the Kind
type for the new kind.
Usually use in wildnessAnimatedTheme
widget. If you want to change the
current context for instance it's recommended to use wildness(KindToReplace)Theme.
Implementation
Wildness replaceKind<Kind extends WildnessBase>({
required WildnessBase<dynamic> kind,
}) {
//Check if the component kind exists in the provide theme components and is the type
assert(
components[kind.type] is Kind,
"Kind must be the same Type or Covariant as the replacemente kind",
);
//Return copyWith of the [wildnessThemeData] components must be unmodifiable
//for being sure of no modifications and no repit hash
return copyWith(
components: Map.unmodifiable(Map.from(components)..addAll({Kind: kind})),
);
}