Skip to content

Add contentTextStyle support to SimpleDialog#178824

Merged
auto-submit[bot] merged 4 commits intoflutter:masterfrom
777genius:fix-simpledialog-contenttextstyle-59462
Feb 17, 2026
Merged

Add contentTextStyle support to SimpleDialog#178824
auto-submit[bot] merged 4 commits intoflutter:masterfrom
777genius:fix-simpledialog-contenttextstyle-59462

Conversation

@777genius
Copy link
Contributor

@777genius 777genius commented Nov 19, 2025

Description

This PR adds contentTextStyle support to SimpleDialog, matching the functionality already available in AlertDialog.

Problem

SimpleDialog was ignoring DialogTheme.contentTextStyle, even though the DialogThemeData.contentTextStyle documentation explicitly states it applies to SimpleDialog.children:

"Overrides the default value for DefaultTextStyle for SimpleDialog.children and AlertDialog.content."

However, only AlertDialog actually implemented this behavior, forcing developers to specify text styles individually on each child widget.

Solution

Added contentTextStyle parameter to SimpleDialog and applied it using DefaultTextStyle, following the same pattern as AlertDialog. The implementation uses the standard fallback chain:

contentTextStyle parameter → DialogTheme.contentTextStyle → M2/M3 defaults

Testing

Added a new test 'SimpleDialog Custom Content Text Style' that verifies contentTextStyle is correctly applied to the children of SimpleDialog.

Related Issues

Fixes #59462

Pre-launch Checklist

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Nov 19, 2025
Copy link
Contributor

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

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 support for contentTextStyle in the SimpleDialog widget, aligning its functionality with AlertDialog. The changes include adding the contentTextStyle parameter to the SimpleDialog constructor and applying it to the dialog's children using DefaultTextStyle. Additionally, the build method of SimpleDialog has been refactored to cache DialogTheme and default theme data, improving readability and preventing redundant lookups. The implementation appears correct and consistent with existing patterns. I've added one comment suggesting the addition of a test to verify the new functionality.

@777genius 777genius force-pushed the fix-simpledialog-contenttextstyle-59462 branch 2 times, most recently from 3884d24 to b6d73d1 Compare November 19, 2025 21:19
@dkwingsmt dkwingsmt self-requested a review November 26, 2025 19:25
Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your work! Also sorry for late review.

@dkwingsmt dkwingsmt requested a review from QuncCccccc January 21, 2026 19:11
Copy link
Contributor

@QuncCccccc QuncCccccc left a comment

Choose a reason for hiding this comment

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

Thanks for adding this! LGTM. I'll add a g3fix to fix the Google testing. The failures look expected since now we added the missing default value for content text style (defaults.contentTextStyle).

@@ -1288,7 +1301,7 @@ class SimpleDialog extends StatelessWidget {
// The paddingScaleFactor is used to adjust the padding of Dialog
// children.
final TextStyle defaultTextStyle =
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think we can rename the variable to effectiveTextStyle. Just feel defaultTextStyle is a bit confusing and effectiveXXX is convention we use for this path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Renamed it to effectiveTitleTextStyle to be more specific — this way it's consistent with effectiveTitlePadding and effectiveContentPadding in the same method. Let me know if you'd prefer just
effectiveTextStyle instead.

expect(materialWidget.clipBehavior, Clip.antiAlias);
});

testWidgets('SimpleDialog Custom Content Text Style', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add one more unit test to berify DialogTheme.contentTextStyle works?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Added the test for DialogTheme.contentTextStyle. Also added Material3/Material2 fallback tests since the docs mention those defaults — figured it's good to have them covered too.

@777genius 777genius force-pushed the fix-simpledialog-contenttextstyle-59462 branch 2 times, most recently from f41904b to 7c485e3 Compare January 28, 2026 11:11
expect(content.text.style, contentTextStyle);
});

testWidgets('SimpleDialog Custom Content Text Style - DialogTheme', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

The linux analyzer is complaining some type issues but should be simple to fix:)
Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Linux analyze passes now. The issue was that the branch was based on an older master.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for review!

@777genius 777genius force-pushed the fix-simpledialog-contenttextstyle-59462 branch 2 times, most recently from 999a20d to c91f381 Compare January 29, 2026 11:52
@QuncCccccc
Copy link
Contributor

QuncCccccc commented Jan 29, 2026

Created g3fix: cl/862354198 and waiting for google testing to pass. Waiting for approvals.

EDIT: the g3fix has been approved.

SimpleDialog now respects contentTextStyle from both the constructor
parameter and DialogTheme, matching AlertDialog behavior.

This implementation follows the existing pattern used for AlertDialog
and titleTextStyle. The DialogThemeData.contentTextStyle property was
already documented to apply to SimpleDialog.children, but was not
actually implemented.

Fixes flutter#59462
- Rename defaultTextStyle to effectiveTitleTextStyle to follow Flutter
  convention for resolved values (consistent with effectiveTitlePadding,
  effectiveContentPadding naming pattern)
- Add test to verify DialogTheme.contentTextStyle works with SimpleDialog
- Add Material3/Material2 theme fallback tests for contentTextStyle
  to ensure documented behavior is covered
@QuncCccccc QuncCccccc force-pushed the fix-simpledialog-contenttextstyle-59462 branch from c91f381 to 94c42c5 Compare February 10, 2026 19:29
@QuncCccccc QuncCccccc added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 10, 2026
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 10, 2026
@auto-submit
Copy link
Contributor

auto-submit bot commented Feb 10, 2026

autosubmit label was removed for flutter/flutter/178824, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

chingjun added a commit to chingjun/flutter that referenced this pull request Feb 11, 2026
This commit adds a `contentTextStyle` flag to `SimpleDialog` to make it
easier to land the internal fixes needed to PR flutter#178824.

The flag currently does nothing. Actual implementation will be landed in
PR flutter#178824.
github-merge-queue bot pushed a commit that referenced this pull request Feb 13, 2026
This commit adds a `contentTextStyle` flag to `SimpleDialog` to make it
easier to land the internal fixes needed to PR #178824.

The flag currently does nothing. Actual implementation will be landed in
PR #178824.
@QuncCccccc QuncCccccc added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 13, 2026
@QuncCccccc QuncCccccc added autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Feb 17, 2026
@auto-submit auto-submit bot added this pull request to the merge queue Feb 17, 2026
Merged via the queue into flutter:master with commit 70870ee Feb 17, 2026
72 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 17, 2026
@777genius
Copy link
Contributor Author

Excellent, well done, thank you all!

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 18, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 18, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 18, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 18, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 18, 2026
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Feb 18, 2026
…11060)

Manual roll requested by [email protected]

flutter/flutter@6e4a481...c023e5b

2026-02-18 [email protected] [web] Pass form validation errors to screen readers via aria-description (flutter/flutter#180556)
2026-02-18 [email protected] Roll Packages from f83926f to 59f905c (10 revisions) (flutter/flutter#182547)
2026-02-18 [email protected] flutter_tools: Copy vendored frameworks from plugin podspecs in ios/macos-framework builds (flutter/flutter#180135)
2026-02-18 [email protected] Marks Windows framework_tests_misc_leak_tracking to be unflaky (flutter/flutter#182534)
2026-02-18 [email protected] Allow TabBar to receive a TabBarScrollController (flutter/flutter#180389)
2026-02-18 [email protected] Clean up cross imports in single_child_scroll_view_test.dart, decorated_sliver_test.dart, draggable_scrollable_sheet_test.dart (flutter/flutter#181613)
2026-02-18 [email protected] Roll Fuchsia Linux SDK from mcN42vw48OPH3JDNm... to Ihau0pUz3u5ajw42u... (flutter/flutter#182530)
2026-02-18 [email protected] Analyzer, require 10.1.0, fix deprecations in dependency_graph.dart (flutter/flutter#182507)
2026-02-17 [email protected] Refactor: Remove material from actions test (flutter/flutter#181702)
2026-02-17 [email protected] [a11y] RangeSlider  mouse interaction should change keyboard focus (flutter/flutter#182185)
2026-02-17 [email protected] Remove more getters from userMessages class (flutter/flutter#182166)
2026-02-17 [email protected] Implement getUniformMatX and getUniformMatXArray functionality on web (flutter/flutter#182249)
2026-02-17 [email protected] Do not wait until dispose before removing replaced/popped page (flutter/flutter#182315)
2026-02-17 [email protected] Add contentTextStyle support to SimpleDialog (flutter/flutter#178824)
2026-02-17 [email protected] Filter error messages from `emulator -list-avds` output (flutter/flutter#180802)
2026-02-17 [email protected] [Reland] Cupertino cross imports (flutter/flutter#182416)
2026-02-17 [email protected] Roll Packages from 09104b0 to f83926f (1 revision) (flutter/flutter#182504)

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

To file a bug in Packages: 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
rickhohler pushed a commit to rickhohler/flutter that referenced this pull request Feb 19, 2026
…2200)

This commit adds a `contentTextStyle` flag to `SimpleDialog` to make it
easier to land the internal fixes needed to PR flutter#178824.

The flag currently does nothing. Actual implementation will be landed in
PR flutter#178824.
rickhohler pushed a commit to rickhohler/flutter that referenced this pull request Feb 19, 2026
## Description

This PR adds `contentTextStyle` support to `SimpleDialog`, matching the
functionality already available in `AlertDialog`.

### Problem

`SimpleDialog` was ignoring `DialogTheme.contentTextStyle`, even though
the `DialogThemeData.contentTextStyle` documentation explicitly states
it applies to `SimpleDialog.children`:

> "Overrides the default value for DefaultTextStyle for
SimpleDialog.children and AlertDialog.content."

However, only `AlertDialog` actually implemented this behavior, forcing
developers to specify text styles individually on each child widget.

### Solution

Added `contentTextStyle` parameter to `SimpleDialog` and applied it
using `DefaultTextStyle`, following the same pattern as `AlertDialog`.
The implementation uses the standard fallback chain:

`contentTextStyle` parameter → `DialogTheme.contentTextStyle` → M2/M3
defaults

### Testing

Added a new test `'SimpleDialog Custom Content Text Style'` that
verifies `contentTextStyle` is correctly applied to the children of
`SimpleDialog`.

## Related Issues

Fixes flutter#59462

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Qun Cheng <[email protected]>
ahmedsameha1 pushed a commit to ahmedsameha1/flutter that referenced this pull request Feb 27, 2026
## Description

This PR adds `contentTextStyle` support to `SimpleDialog`, matching the
functionality already available in `AlertDialog`.

### Problem

`SimpleDialog` was ignoring `DialogTheme.contentTextStyle`, even though
the `DialogThemeData.contentTextStyle` documentation explicitly states
it applies to `SimpleDialog.children`:

> "Overrides the default value for DefaultTextStyle for
SimpleDialog.children and AlertDialog.content."

However, only `AlertDialog` actually implemented this behavior, forcing
developers to specify text styles individually on each child widget.

### Solution

Added `contentTextStyle` parameter to `SimpleDialog` and applied it
using `DefaultTextStyle`, following the same pattern as `AlertDialog`.
The implementation uses the standard fallback chain:

`contentTextStyle` parameter → `DialogTheme.contentTextStyle` → M2/M3
defaults

### Testing

Added a new test `'SimpleDialog Custom Content Text Style'` that
verifies `contentTextStyle` is correctly applied to the children of
`SimpleDialog`.

## Related Issues

Fixes flutter#59462

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Qun Cheng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add dialog theme for Simple Dialogs

3 participants