provide-icon-semantic-label
Warns when Icon does not have a semanticLabel.
When developers use standalone Icon widgets (e.g. Icon(Icons.star)) as visual indicators without text, omitting the semanticLabel causes Flutter to exclude the icon from the semantics tree entirely.
This renders meaningful visual icons completely invisible to screen readers like VoiceOver.
⚙️ Config
Set allow-empty (default is true) to configure whether an empty string value is allowed to be used as a label.
analysis_options.yaml
dcm:
rules:
- provide-icon-semantic-label:
allow-empty: true
Example
❌ Bad:
// LINT: Provide a semantic label to icons.
Icon();
// LINT: Provide a semantic label to icons.
ImageIcon();
✅ Good:
Icon(semanticLabel: 'some label');
ExcludeSemantics(child: Icon());