computeDrawOrder method Null safety

void computeDrawOrder()

Implementation

void computeDrawOrder() {
  _drawables.clear();
  _rules.clear();
  buildDrawOrder(_drawables, null, _rules);

  // Build rule dependencies. In practice this'll need to happen anytime a
  // target drawable is changed or rule is added/removed.
  var root = DrawTarget();
  // Make sure all dependents are empty.
  for (final nodeRules in _rules) {
    for (final target in nodeRules.targets) {
      target.dependents.clear();
    }
  }

  // Now build up the dependencies.
  for (final nodeRules in _rules) {
    for (final target in nodeRules.targets) {
      root.dependents.add(target);
      var dependentRules = target.drawable?.flattenedDrawRules;
      if (dependentRules != null) {
        for (final dependentRule in dependentRules.targets) {
          dependentRule.dependents.add(target);
        }
      }
    }
  }

  var sorter = DependencySorter<Component>();

  _sortedDrawRules = sorter.sort(root).cast<DrawTarget>().skip(1).toList();

  sortDrawOrder();
}