getTokensOfType function
Returns a map of all tokens for a specific type.
When fallbackSetData
is set tokenSetData
gets merged and overridden
with the provided map.
Implementation
Map<String, dynamic> getTokensOfType(
String type, {
required Map<String, dynamic> tokenSetData,
Map<String, dynamic>? fallbackSetData,
}) {
final tokens = Map.fromEntries(
tokenSetData.entries.where((element) => hasNestedType(element, type: type)),
);
if (fallbackSetData != null) {
final fallbackTokens = Map.fromEntries(
fallbackSetData.entries
.where((element) => hasNestedType(element, type: type)),
);
return overrideAndMergeTokenSet(fallbackTokens, withSet: tokens);
}
return tokens;
}