Severity: AnalysisErrorSeverity.WARNING
Maturity: stable
Since 1.0.0
This diagnostic detects when a prop that has a default value in a function component is used directly instead of its defaulted equivalent, since this is usually a mistake, and can result in unexpected null errors.
BAD: props.content
is used instead of content
which defaults the prop.
import 'package:over_react/over_react.dart';
part 'foo.over_react.g.dart';
UiFactory<FooProps> Foo = uiFunction(
(props) {
// Default props
final content = props.content ?? 'abc';
return Dom.div()(props.content);
},
_$FooConfig, // ignore: undefined_identifier
);
mixin FooProps on UiProps {
String content;
}
GOOD:
import 'package:over_react/over_react.dart';
part 'foo.over_react.g.dart';
UiFactory<FooProps> Foo = uiFunction(
(props) {
// Default props
final content = props.content ?? 'abc';
return Dom.div()(content);
},
_$FooConfig, // ignore: undefined_identifier
);
mixin FooProps on UiProps {
String content;
}