combine static method

MixScope combine({
  1. required Iterable<MixScope> scopes,
  2. required Widget child,
  3. Key? key,
})

Combines multiple MixScope instances into a single scope.

Implementation

static MixScope combine({
  required Iterable<MixScope> scopes,
  required Widget child,
  Key? key,
}) {
  if (scopes.isEmpty) return MixScope.empty(key: key, child: child);

  final combined = scopes.fold<MixScope>(
    MixScope.empty(child: child),
    (previous, scope) => previous.merge(scope),
  );

  return MixScope._(
    key: key,
    tokens: combined._tokens,
    orderOfModifiers: combined.orderOfModifiers,
    child: child,
  );
}