hardcoded_strings_lint
2.1.1, released 3 months ago by an unverified publisher
A custom Dart analyzer plugin that detects hardcoded strings in widget constructors.
What it does
Identifies hardcoded strings passed directly to Flutter widget constructor arguments and provides quick fixes for ignoring or extracting them. It skips technical patterns, short strings, map keys, and acceptable widget properties.
AI-written summary of version 2.1.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to enforce internationalization practices across your Flutter codebase
- You want automated quick fixes to extract literals to constants or add ignore comments
Skip it when
- You rely strictly on `flutter analyze` instead of `dart analyze` or your IDE (as `flutter analyze` does not run analyzer plugins)
- Your project does not require localization or strict code maintainability rules
Strengths
- Integrates natively with `dart analyze` and the Dart Analysis Server without extra CLI commands
- Smart filtering skips technical patterns like URLs, emails, hex colors, and file paths
- Provides quick fixes including extracting to variables and updating `analysis_options.yaml`
Weaknesses
- Does not run under `flutter analyze`
- Requires updating `analysis_options.yaml` with top-level `plugins` block
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 5
Configure the plugin under the top-level `plugins:` block in `analysis_options.yaml` and restart your IDE or run `dart pub get`.
class WelcomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Welcome to Our App'), // flagged
),
);
}
}Alternatives
Packages that do the same job and could replace hardcoded_strings_lint.
- lints
If you prefer official Dart lint rules rather than a custom third-party analyzer plugin.
86Compare - flutter_lints
If you only need the recommended Flutter lint rules set.
83Compare
Works with
Packages commonly used together with hardcoded_strings_lint: ones it builds on, ones built on it, and its own family.
- analyzerhardcoded_strings_lint depends on itPerforms static analysis of Dart code for tool integration and embedding.
- yamlhardcoded_strings_lint depends on itA Dart library for parsing YAML documents into Dart data structures.
- yaml_edithardcoded_strings_lint depends on itYAML manipulation library preserving comments and whitespace
- analyzer_pluginhardcoded_strings_lint depends on itFramework for building plugins for the Dart analysis server
- analysis_server_pluginhardcoded_strings_lint depends on itFramework and support code for building plugins for the Dart analysis server.