Skip to content

[material_ui] Add Checkbox.markInsets - #12690

Merged
auto-submit[bot] merged 10 commits into
flutter:mainfrom
Munawer-Ali:checkbox-mark-insets
Oct 27, 2026
Merged

auto-submit[bot] merged 10 commits into
flutter:mainfrom
Munawer-Ali:checkbox-mark-insets

Conversation

@Munawer-Ali

@Munawer-Ali Munawer-Ali commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

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

Adds Checkbox.markInsets and CheckboxThemeData.markInsets, which inset the check
mark and the
indeterminate dash within the checkbox without changing the size of the box itself. The
mark and its
stroke shrink proportionally, and the mark is not painted if the insets leave no room.

Fixes flutter/flutter#188031

Tests

Added to packages/material_ui/test/checkbox_test.dart:

  • Checkbox.markInsets defaults to null
  • Checkbox with no markInsets paints the check at full stroke width (backward-compat)
  • Checkbox.markInsets shrinks the check mark and its stroke
  • Checkbox.markInsets shrinks the indeterminate dash
  • Checkbox.markInsets larger than the box collapses the mark without crashing
  • Checkbox.markInsets falls back to CheckboxThemeData.markInsets
  • Checkbox.markInsets overrides CheckboxThemeData.markInsets

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

@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.');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Checkbox is a const constructor, so this suggestion won't compile. We should assert on the markInsets setter below instead.

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.');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same comment as above, Checkbox.adaptive is a const constructor, so this suggestion won't compile.

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
  }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Valid suggestion, but assert(value.isNonNegative, 'markInsets must be non-negative.') is more readable.

@elliette
elliette requested review from QuncCccccc and removed request for QuncCccccc September 1, 2026 21:32
@elliette

elliette commented Sep 1, 2026

Copy link
Copy Markdown
Member

Thank you for your contribution! Because of the volume of PRs we receive, we require that new contributors use our checklist to guide them through critical steps in creating a Flutter PR. This PR's description is missing that checklist, so it is being marked as a Draft.

Please edit the PR description to add the checklist, then ensure that you have completed all of the steps. Once you've done that, please mark the PR as ready for review.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@elliette
elliette marked this pull request as draft September 1, 2026 21:32
@Munawer-Ali
Munawer-Ali marked this pull request as ready for review September 2, 2026 05:55
@Munawer-Ali

Copy link
Copy Markdown
Contributor Author

@elliette Thanks! I've added the Pre-Review Checklist to the description and completed the steps.
Marking as ready for review.

@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, allowing the check mark and indeterminate dash to be inset and scaled proportionally within the checkbox. The reviewer recommends adding assertions to the Checkbox, Checkbox.adaptive, and CheckboxThemeData constructors to enforce that markInsets values are non-negative, along with a corresponding unit test to verify this validation.

@QuncCccccc QuncCccccc 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.

LGTM. Thank you for helping port over the fix!

@QuncCccccc QuncCccccc added the CICD Run CI/CD label Sep 2, 2026
@QuncCccccc
QuncCccccc requested a review from elliette September 2, 2026 21:37
@elliette elliette added CICD Run CI/CD and removed CICD Run CI/CD labels Sep 2, 2026
/// {@endtemplate}
final String? semanticLabel;

/// {@template flutter.material.checkbox.markInsets}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be {@template material_ui.checkbox.markInsets} now :)

/// If specified, overrides the default value of [Checkbox.side].
final BorderSide? side;

/// {@macro flutter.material.checkbox.markInsets}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also here {@macro material_ui.checkbox.markInsets}

- Adds `Checkbox.markInsets` and `CheckboxThemeData.markInsets`, which inset the
check mark (and the indeterminate dash) within the checkbox without changing the
size of the box itself. The mark and its stroke shrink proportionally.
version: minor No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add a new line at the end of this file

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 4, 2026
@Munawer-Ali

Copy link
Copy Markdown
Contributor Author

Thanks for the review @elliette Updated the dartdoc template and macro to
material_ui.checkbox.markInsets in both files, and added the trailing newline
to the changelog file.

@Munawer-Ali

Copy link
Copy Markdown
Contributor Author

@QuncCccccc Hi Ma’am, could you please review and approve the changes in this PR when you have a chance? Thank you!

@QuncCccccc QuncCccccc added the CICD Run CI/CD label Sep 10, 2026

@QuncCccccc QuncCccccc 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.

LGTM. Thanks!

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 12, 2026
@Munawer-Ali

Copy link
Copy Markdown
Contributor Author

Hi @elliette , could you please take a look at this PR when you get a chance?

@Munawer-Ali

Copy link
Copy Markdown
Contributor Author

@QuncCccccc Sorry to disturb you again, Ma’am. Could you please ask @elliette to review this PR as well when you get a chance?

Thank you so much for your support! 🙏

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Checkbox is a const constructor, so this suggestion won't compile. We should assert on the markInsets setter below instead.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same comment as above, Checkbox.adaptive is a const constructor, so this suggestion won't compile.

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
Member

Choose a reason for hiding this comment

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

Valid suggestion, but assert(value.isNonNegative, 'markInsets must be non-negative.') is more readable.

///
/// This insets the check mark inward; the size of the checkbox box itself
/// is not affected. The check mark and its stroke shrink to fit the
/// remaining space, so the mark stays proportional.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"so the mark stays proportional"

Please add some test cases to confirm this - currently they are all using EdgeInsets.all (e.g. test with EdgeInsets.only(left: 9)).

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.

I agree. I suggest adding the following sentence at the end of this paragraph for clarity:

  /// Its size is the smaller of the remaining width and height, and it is
  /// centered in the remaining space, so an inset on one axis also shrinks it
  /// on the other. For example, `EdgeInsets.only(left: 9.0)` draws a
  /// half-size mark centered in the right half of the box.

and also adding a test for this case.

@QuncCccccc QuncCccccc added the CICD Run CI/CD label Sep 30, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 30, 2026
@elliette elliette added the CICD Run CI/CD label Sep 30, 2026

@elliette elliette left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! One more suggestion otherwise looks good

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Oct 1, 2026
@Munawer-Ali
Munawer-Ali requested a review from elliette October 2, 2026 21:16
@QuncCccccc QuncCccccc added the CICD Run CI/CD label Oct 2, 2026
@Munawer-Ali

Copy link
Copy Markdown
Contributor Author

@QuncCccccc please ask @elliette to review it again when they have a chance?

@QuncCccccc
QuncCccccc requested a review from dkwingsmt October 6, 2026 21:16
@Munawer-Ali

Copy link
Copy Markdown
Contributor Author

Hi @QuncCccccc, thanks for approving my PR! Could you please help get the remaining review from the other reviewer so we can move forward with merging it? I’d really appreciate your help. Thanks again!

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Oct 15, 2026
@Munawer-Ali

Copy link
Copy Markdown
Contributor Author

Thanks @dkwingsmt ! Added the suggested sentence to the markInsets docs and a test.

@Munawer-Ali

Copy link
Copy Markdown
Contributor Author

@QuncCccccc please ask @elliette or @dkwingsmt to review it again when they have a chance?

@elliette elliette left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for your patience! Looks good

@elliette elliette added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 22, 2026

@dkwingsmt dkwingsmt 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.

LGTM. Thank you for keeping polishing it!

@dkwingsmt dkwingsmt added the CICD Run CI/CD label Oct 26, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Oct 26, 2026
@QuncCccccc QuncCccccc added the CICD Run CI/CD label Oct 26, 2026
@auto-submit
auto-submit Bot merged commit d2e97da into flutter:main Oct 27, 2026
13 checks passed
GhagSagar23 pushed a commit to Kryonex-Labs/flutter that referenced this pull request Oct 27, 2026
flutter/packages@23a05b6...a8549ae

2026-10-27 [email protected] [material_ui]
Deprecate the black/white parameters in `Typography.material2021`
(flutter/packages#13443)
2026-10-27 [email protected] [shared_preferences] Defer
SharedPreferences fetch in `LegacySharedPreferencesPlugin` until first
use on Android (flutter/packages#13431)
2026-10-27 [email protected] [material_ui] Fix MenuAnchor
non-Unicode shortcut labels on JS web (flutter/packages#13370)
2026-10-27 [email protected] [material_ui]
Add Checkbox.markInsets (flutter/packages#12690)
2026-10-27 [email protected]
[vector_graphics_compiler] Handle coordinate lists on text and tspan
(flutter/packages#13287)
2026-10-27 [email protected]
[cupertino_ui] Unskip web tests that pass on CanvasKit and Skwasm:
nav_bar_transition_test, refresh_test, route_test,
text_field_cursor_test (flutter/packages#13439)
2026-10-27 [email protected] [material_ui] Fix
`TextTheme` and `Typography` `debugFillProperties` defaults
(flutter/packages#13374)
2026-10-27 [email protected] [material_ui]
Update out-of-date typography documentation (flutter/packages#13372)
2026-10-27 [email protected] [shared_preferences_foundation] Fix web
compilation of apps that import the package (flutter/packages#13447)
2026-10-26 [email protected] Fix AI guidelines link in PR template
(flutter/packages#13411)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
flutter/packages@23a05b6...a8549ae

2026-10-27 [email protected] [material_ui]
Deprecate the black/white parameters in `Typography.material2021`
(flutter/packages#13443)
2026-10-27 [email protected] [shared_preferences] Defer
SharedPreferences fetch in `LegacySharedPreferencesPlugin` until first
use on Android (flutter/packages#13431)
2026-10-27 [email protected] [material_ui] Fix MenuAnchor
non-Unicode shortcut labels on JS web (flutter/packages#13370)
2026-10-27 [email protected] [material_ui]
Add Checkbox.markInsets (flutter/packages#12690)
2026-10-27 [email protected]
[vector_graphics_compiler] Handle coordinate lists on text and tspan
(flutter/packages#13287)
2026-10-27 [email protected]
[cupertino_ui] Unskip web tests that pass on CanvasKit and Skwasm:
nav_bar_transition_test, refresh_test, route_test,
text_field_cursor_test (flutter/packages#13439)
2026-10-27 [email protected] [material_ui] Fix
`TextTheme` and `Typography` `debugFillProperties` defaults
(flutter/packages#13374)
2026-10-27 [email protected] [material_ui]
Update out-of-date typography documentation (flutter/packages#13372)
2026-10-27 [email protected] [shared_preferences_foundation] Fix web
compilation of apps that import the package (flutter/packages#13447)
2026-10-26 [email protected] Fix AI guidelines link in PR template
(flutter/packages#13411)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD 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.

Add a padding property to Checkbox widget ✅ around check icon ✔.

4 participants