Skip to main content

prefer-merge-semantics-composite

effort: 2m
configurable
has IDE fix
pro+

Warns when a Column, Row or Flex widget with the configured children is not wrapped in MergeSemantics.

Without MergeSemantics, screen readers treat those interactive children widgets as separate, fragmented focus stops.

note

This rule requires configuration in order to highlight any issues.

⚙️ Config​

Set entries (default is empty) to configure the list of widget pairs.

analysis_options.yaml
dcm:
rules:
- prefer-merge-semantics-composite:
entries:
- Text + Checkbox
- Text + Button

Example​

❌ Bad:

// LINT: This widget contains the configured interactive widgets and should be wrapped with 'MergeSemantics'.
Row(children: [Text(), Checkbox()]);

// LINT: This widget contains the configured interactive widgets and should be wrapped with 'MergeSemantics'.
Column(children: [Text(), Checkbox()]);

✅ Good:

MergeSemantics(child: Row(children: [Text(), Checkbox()]));
MergeSemantics(child: Column(children: [Text(), Checkbox()]));