disableRequiredPropValidation property

Set<String>? disableRequiredPropValidation
final

Names of props to opt out of required prop validation for, both statically in the analyzer plugin and at runtime when invoking the builder (only with asserts enabled).

Useful when you have a wrapper component that sets required prop manually.

For example:

mixin FooProps on UiProps {
  late String requiredPropAlwaysSetInWrapper;
  late String requiredPropNotSetInWrapper;
}

UiFactory<FooProps> Foo = uiFunction((props) {
  // ...
}, _$FooConfig);

@Props(disableRequiredPropValidation: {'requiredPropAlwaysSetInWrapper'})
class WrapperProps = UiProps with FooProps, WrapperPropsMixin;

UiFactory<WrapperProps> Wrapper = uiForwardRef((props, ref) {
  return (Foo()
    ..requiredPropAlwaysSetInWrapper = 'foo'
    ..addProps(props.getPropsToForward(exclude: {WrapperPropsMixin}))
    ..ref = ref
  )();
}, _$WrapperConfig);

Implementation

final Set<String>? disableRequiredPropValidation;