Skip to content

[material_ui] Add Checkbox.markInsets - #12690

Open
Munawer-Ali wants to merge 1 commit into
flutter:mainfrom
Munawer-Ali:checkbox-mark-insets
Open

[material_ui] Add Checkbox.markInsets#12690
Munawer-Ali wants to merge 1 commit into
flutter:mainfrom
Munawer-Ali:checkbox-mark-insets

Conversation

@Munawer-Ali

Copy link
Copy Markdown

This PR ports my changes from flutter/flutter#188258 to
flutter/packages,
as part of flutter/flutter#188444.

@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage labels Aug 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces 'markInsets' to 'Checkbox' and 'CheckboxThemeData' to allow insetting the check mark and indeterminate dash within the checkbox, shrinking them proportionally without altering the overall box size. The feedback suggests adding assertions in the 'Checkbox' constructors and the '_CheckboxPainter' setter to enforce that 'markInsets' is non-negative, as specified in the documentation.

Comment on lines 118 to 119
}) : _checkboxType = _CheckboxType.material,
assert(tristate || value != null);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since the documentation for markInsets states that it "Must be non-negative", we should enforce this constraint with an assertion in the constructor to catch invalid values early in development.

  }) : _checkboxType = _CheckboxType.material,
       assert(tristate || value != null),
       assert(markInsets == null || (markInsets.left >= 0.0 && markInsets.top >= 0.0 && markInsets.right >= 0.0 && markInsets.bottom >= 0.0), 'markInsets must be non-negative.');

Comment on lines 159 to 160
}) : _checkboxType = _CheckboxType.adaptive,
assert(tristate || value != null);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similarly, we should add the non-negative assertion for markInsets in the Checkbox.adaptive constructor.

  }) : _checkboxType = _CheckboxType.adaptive,
       assert(tristate || value != null),
       assert(markInsets == null || (markInsets.left >= 0.0 && markInsets.top >= 0.0 && markInsets.right >= 0.0 && markInsets.bottom >= 0.0), 'markInsets must be non-negative.');

Comment on lines +740 to +746
set markInsets(EdgeInsets value) {
if (_markInsets == value) {
return;
}
_markInsets = value;
notifyListeners(); // triggers repaint when it changes
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure that invalid negative insets provided via CheckboxThemeData (which doesn't have constructor assertions) are also caught before they cause rendering anomalies, we should add an assertion in the _CheckboxPainter.markInsets setter.

  set markInsets(EdgeInsets value) {
    if (_markInsets == value) {
      return;
    }
    assert(value.left >= 0.0 && value.top >= 0.0 && value.right >= 0.0 && value.bottom >= 0.0, 'markInsets must be non-negative.');
    _markInsets = value;
    notifyListeners(); // triggers repaint when it changes
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: material_ui triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant