Severity: AnalysisErrorSeverity.INFO
Maturity: stable
Since 1.0.0
PREFER to use the return value of createRef()
as the ref field value.
GOOD:
class NavItemWrapperComponent extends UiComponent<NavItemWrapperProps> {
final _navItemRef = createRef<NavItemComponent>();
@override
render() {
return (NavItem()
..modifyProps(addUnconsumedProps)
..ref = _navItemRef
)(props.children);
}
}
BAD:
class NavItemWrapperComponent extends UiComponent<NavItemWrapperProps> {
NavItemComponent _navItemRef;
@override
render() {
return (NavItem()
..modifyProps(addUnconsumedProps)
..ref = (ref) { _navItemRef = ref; }
)(props.children);
}
}
Read more about createRef()