decorateRootNodeWithPlatformClasses function

void decorateRootNodeWithPlatformClasses({
  1. List<Feature> features = const [],
  2. bool includeDefaults = true,
  3. Element? rootNode,
  4. VoidCallback? callback,
})

Appends CSS classes generated by getPlatformClasses to the specified rootNode.

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

By default, rootNode is document.documentElement.

Implementation

void decorateRootNodeWithPlatformClasses(
    {List<Feature> features = const [],
    bool includeDefaults = true,
    Element? rootNode,
    VoidCallback? callback}) {
  rootNode ??= document.documentElement;

  if (rootNode != null && !nodeHasBeenDecorated(rootNode)) {
    var existingClasses = rootNode.classes.toList();

    rootNode.className = getPlatformClasses(
        features: features,
        includeDefaults: includeDefaults,
        existingClasses: existingClasses);

    callback?.call();
  }
}