replaceKind<Kind extends ElementaryBase> method
Replace current kind in the ElementaryThemeData.
If the kind exist already in Elementary components and is Type or Covariant
of the provide Kind then replace the Kind type for the new kind.
Usually use in ElementaryAnimatedTheme widget. If you want to change the
current context for instance it's recommended to use Elementary(KindToReplace)Theme.
Implementation
Elementary replaceKind<Kind extends ElementaryBase>({
required ElementaryBase<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 [ElementaryThemeData] 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})),
);
}