decorateRootNodeWithPlatformClasses function

void decorateRootNodeWithPlatformClasses({
  1. List<Feature>? features,
  2. bool includeDefaults = true,
  3. Element? rootNode,
  4. void 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,
    bool includeDefaults = true,
    Element? rootNode,
    void Function()? callback}) {
  rootNode ??= document.documentElement;

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

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

    if (callback != null) callback();
  }
}