waste_lens_lints 0.1.0
waste_lens_lints: ^0.1.0 copied to clipboard
custom_lint rules for waste_lens: missing dispose, non-const widgets, setState during build, and images without cache dimensions.
waste_lens_lints example #
Enable the rules in any Flutter package.
pubspec.yaml:
dev_dependencies:
waste_lens_lints: ^0.1.0
custom_lint: ^0.8.1
analysis_options.yaml:
analyzer:
plugins:
- custom_lint
Then run:
dart run custom_lint
What gets flagged #
class _MyState extends State<MyWidget> {
final controller = TextEditingController(); // dispose_required: never disposed
@override
Widget build(BuildContext context) {
setState(() {}); // no_setstate_in_build
return Column(
children: [
Text('static'), // prefer_const_widget
Image.network('https://x/y.png'), // image_needs_cache_dimensions
],
);
}
}
Runnable good/bad fixtures for every rule live in
test/fixtures/.