over_react_required_prop

Severity: AnalysisErrorSeverity.INFO

Maturity: experimental

Since 1.0.0

View the Project on GitHub workiva/over_react

PREFER to always provide a value for props that are annotated a @requiredProps.

If a component has a props interface like this:

mixin NavItemProps on UiProps {
  bool isActive;
  @requiredProp
  void Function() onDidActivate;
}

then the prop that is marked as "required" should always be set by the consumer:

GOOD:

@override
render() {
  return (NavItem()
    ..onDidActivate = () {
      // Do something
    }
  )(
    'Activate me',
  );
}

BAD:

@override
render() {
  return NavItem()(
    'You probably cannot activate me :(',
  );
}