freezedVariants function
Future<List<UnionVarianInfo> >
freezedVariants(
- InterfaceElement clazz,
- GeneratorCtx ctx, {
- required bool isInput,
Implementation
Future<List<UnionVarianInfo>> freezedVariants(
InterfaceElement clazz,
GeneratorCtx ctx, {
required bool isInput,
}) async {
final constructors =
clazz.constructors.where(isFreezedVariantConstructor).toList();
final isUnion = !isInput && constructors.length > 1;
final inputConfig = inputTypeAnnotation(clazz);
final classConfig = getClassConfig(ctx, clazz);
final Iterable<Future<FieldInfo>> _unionClassFields = isInput
? []
: fieldsFromClass(
clazz,
ctx,
isInput: isInput,
);
return Future.wait(
constructors.map(
(con) => classInfoFromConstructor(
ctx,
clazz,
con,
isUnion: isUnion,
unionClassFields: _unionClassFields,
classConfig: classConfig,
inputConfig: inputConfig,
),
),
);
}