of<T extends Object> static method

FrUnion of<T extends Object>(
  1. Set<T> models
)

Implementation

static FrUnion of<T extends Object>(Set<T> models) {
  final taggedModels = models.whereType<TaggedUnionModel>().toSet();

  if (taggedModels.isEmpty) {
    return FrUnion.ofModel(models.cast<FrUnionModel>().toSet());
  }

  if (taggedModels.length == models.length) {
    return FrUnion.ofTaggedModel(taggedModels);
  }

  throw ArgumentError.value(
    models,
    'models',
    'FrUnion.of expects either model values or tagged model tuples.',
  );
}