getPlatformClasses function

String getPlatformClasses({
  1. List<Feature>? features,
  2. bool includeDefaults = true,
  3. List<String> existingClasses = const [],
})

Generates CSS classes based on the current browser, operatingSystem and optionally, features that your app may need conditional styling for in addition to the defaultFeatureCssClassDecorators that will have CSS classes present by default.

If you do not want defaultFeatureCssClassDecorators to be used, set includeDefaults to false.

Implementation

String getPlatformClasses(
    {List<Feature>? features,
    bool includeDefaults = true,
    List<String> existingClasses = const []}) {
  var allFeatures = Set<Feature>.from(features ?? []);

  if (includeDefaults) allFeatures.addAll(defaultFeatureCssClassDecorators);

  var classes = <String>[]
    ..addAll(existingClasses)
    ..add(browserClassPrefix + browserClassName)
    ..add(getBrowserVersionClasses())
    ..add(osClassPrefix + osClassName)
    ..add(getFeatureSupportClasses(allFeatures))
    ..add(decorationCompleteClassName);

  return listToClassNameString(classes);
}