assertIsRealType function
Asserts that the given type is not a token reference type.
Used in testing to ensure proper type usage in generics.
Implementation
@visibleForTesting
void assertIsRealType(Type value) {
// Only check if the value is a TokenRef type that should be replaced
final Type? realType = switch (value) {
// Color types
== ColorRef => Color,
// Border types
== BorderSideRef => BorderSide,
== BoxBorderRef => BoxBorder,
== BorderRadiusRef => BorderRadius,
== BorderRadiusDirectionalRef => BorderRadiusDirectional,
== BorderRadiusGeometryRef => BorderRadiusGeometry,
// Gradient types
== GradientRef => Gradient,
== LinearGradientRef => LinearGradient,
== RadialGradientRef => RadialGradient,
== SweepGradientRef => SweepGradient,
== GradientTransformRef => GradientTransform,
// Geometry types
== AlignmentGeometryRef => AlignmentGeometry,
== AlignmentRef => Alignment,
== AlignmentDirectionalRef => AlignmentDirectional,
== EdgeInsetsGeometryRef => EdgeInsetsGeometry,
== EdgeInsetsRef => EdgeInsets,
== EdgeInsetsDirectionalRef => EdgeInsetsDirectional,
// Shape and decoration types
== RadiusRef => Radius,
== OffsetRef => Offset,
== RectRef => Rect,
== ShadowRef => Shadow,
== BoxShadowRef => BoxShadow,
== BoxDecorationRef => BoxDecoration,
== DecorationImageRef => DecorationImage,
== ShapeBorderRef => ShapeBorder,
== BoxConstraintsRef => BoxConstraints,
// Text types
== TextStyleRef => TextStyle,
== StrutStyleRef => StrutStyle,
== TextHeightBehaviorRef => TextHeightBehavior,
== TextScalerRef => TextScaler,
== FontFeatureRef => FontFeature,
== FontWeightRef => FontWeight,
// Other types
== LocaleRef => Locale,
== ImageProviderRef => ImageProvider,
== Matrix4Ref => Matrix4,
== TableColumnWidthRef => TableColumnWidth,
== TableBorderRef => TableBorder,
== DurationRef => Duration,
== CurveRef => Curve,
// All other types are valid - not TokenRef types
_ => null,
};
assert(
realType == null,
'Cannot use $value for generic, use $realType instead.',
);
}