15
6
DO return the result of an expression directly instead of assigning it to a variable and then returning the variable.
int add(int a, int b) { final result = a + b; return result; }
int add(int a, int b) { return a + b; }
To enable the prefer_immediate_return rule, add prefer_immediate_return under custom_lint > rules in your analysis_options.yaml file:
prefer_immediate_return
analysis_options.yaml
custom_lint: rules: - prefer_immediate_return