-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add automaticallyImplyActions property to AppBar
#171113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1. This adds a new boolean property automaticallyImplyActions (default: true) to the AppBar 2. When an AppBar is used inside a Scaffold that has an end drawer and the AppBar's actions list is null or empty, a menu button is automatically added to open the endDrawer. 3. Setting automaticallyImplyActions to false disables this behavior, allowing full manual control over the AppBar's actions.
|
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. |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Rationale for
|
|
Hi, thanks for your contribution. Can you add some unit tests? |
…tomaticallyImplyActions
|
Hi @dkwingsmt, Tests have been added for both These cover default behavior, suppression with false, and behavior when custom actions are provided. |
|
Any update on this @k-arindam @dkwingsmt ? |
|
Hi @nuuuron, we're waiting for @dkwingsmt's review! |
|
Sorry this PR slipped through my review queue! I'll look at it soon! |
dkwingsmt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
|
This needs a second approval to land. I've sent it out for a another review. |
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @k-arindam! Welcome! Thanks for contributing. It looks like the analyzer is failing here currently, it looks like this needs dart format run. Can you take a look?
|
Hey @Piinks, let me have a look! |
|
Hey @Piinks, running |
Hmm that does not sound right. I wonder, have you rebased with the tip of the tree? We bumped the Dart version since you opened this PR and it introduced a different formatting style. |
|
Or can you try |
|
I'll have a look into it now, and will keep you guys updated here! Also some tests are failing specially some linux & mac ones after merging the flutter/master, whats going on ?!? 🤔 |
|
Those are probably flakes. Rerunning them (or updating with base branch) usually resolves them (some infra flakes might need waiting until work hours). If you find resolving the formatting error too hard you may also manually apply them for now, which is a simple fix here: git apply <<DONE
diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart
index fa0e4dd2f85..00000000000 100644
--- a/packages/flutter/test/material/app_bar_test.dart
+++ b/packages/flutter/test/material/app_bar_test.dart
@@ -973,7 +973,9 @@ void main() {
'AppBar draws menu for end drawer if automaticallyImplyActions is true (default) and actions is null',
(WidgetTester tester) async {
await tester.pumpWidget(
- MaterialApp(home: Scaffold(endDrawer: const Drawer(), appBar: AppBar())),
+ MaterialApp(
+ home: Scaffold(endDrawer: const Drawer(), appBar: AppBar()),
+ ),
);
expect(find.byIcon(Icons.menu), findsOneWidget);
},
@@ -3624,3 +3626,4 @@ void main() {
);
});
}
DONE |
Thanks @dkwingsmt 👆🏼! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 . This can land regardless of whether or not you decide to add the assertion I mentioned in my comment below.
flutter/flutter@afba7d7...20788c0 2025-07-24 [email protected] Roll Packages from 9c85e5e to 963550c (4 revisions) (flutter/flutter#172696) 2025-07-24 [email protected] Add missing deprecations to CupertinoDynamicColor. (flutter/flutter#171160) 2025-07-24 [email protected] Roll Dart SDK from a181fe571dc8 to 26dece893751 (2 revisions) (flutter/flutter#172683) 2025-07-24 [email protected] Migrate to null aware elements - Part 1 (flutter/flutter#172198) 2025-07-24 [email protected] licenses_cpp: implements extracting regions from matched text (flutter/flutter#172655) 2025-07-24 [email protected] Roll pub packages (flutter/flutter#172677) 2025-07-24 [email protected] Marks Mac_ios keyboard_hot_restart_ios to be unflaky (flutter/flutter#168053) 2025-07-24 [email protected] Roll Abseil and remove a workaround for a Fuchsia target that was unable to build Abseil (flutter/flutter#172665) 2025-07-24 [email protected] Add `automaticallyImplyActions` property to AppBar (flutter/flutter#171113) 2025-07-24 [email protected] fix: TabBar fontFamily inheritance with custom label styles (flutter/flutter#171699) 2025-07-23 [email protected] Marks Linux_mokey new_gallery__crane_perf to be unflaky (flutter/flutter#167633) 2025-07-23 [email protected] [android] Fix broken `--android-skip-build-dependency-validation` flag (flutter/flutter#172581) 2025-07-23 [email protected] Fix: Ensure Text widget locale is included in semantics language tag (flutter/flutter#172034) 2025-07-23 [email protected] [Web][a11y] Update selected chips semantics (flutter/flutter#172660) 2025-07-23 [email protected] Roll Skia from eea1c33fbe84 to 094ac350125f (29 revisions) (flutter/flutter#172664) 2025-07-23 [email protected] Marks Mac_arm64_ios imitation_game_flutter to be unflaky (flutter/flutter#168052) 2025-07-23 [email protected] Roll Dart SDK from a31774a3d049 to a181fe571dc8 (2 revisions) (flutter/flutter#172667) 2025-07-23 [email protected] Adapt xcresult parser for Xcode 16 changes (flutter/flutter#172596) 2025-07-23 [email protected] Update excluded_files to match the current output of the old license checker (flutter/flutter#172670) 2025-07-23 [email protected] Manual Roll of Dart SDK from da9e0299c120 to a31774a3d049 (flutter/flutter#172616) 2025-07-23 [email protected] [FGP] Small restructuring of Android Studio native flutter dependency support (flutter/flutter#172651) 2025-07-23 [email protected] revert: Replaces legacy licenses check with licenses_cpp (flutter/flutter#172568) 2025-07-23 [email protected] fix: size-exp naming (flutter/flutter#172647) 2025-07-23 [email protected] Roll Fuchsia Test Scripts from MnFlN7VWM_7h7EmBV... to BWj3yYC74ud58QhN0... (flutter/flutter#172646) 2025-07-23 [email protected] [DisplayList] implement shadow bounds without relying on Skia utilities (flutter/flutter#172572) 2025-07-23 [email protected] Update `dev/bots/post_process_docs.dart` to use `flutter.version.json` (flutter/flutter#172601) 2025-07-23 [email protected] Emit a warning on `--[no-]disable-dds`, preferring `--no-dds` (flutter/flutter#172595) 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] 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
## Summary - This PR adds a new boolean property `automaticallyImplyActions` to the `AppBar` widget. - It provides fine-grained control over whether an automatic menu icon (`Icons.menu`) is added when an `endDrawer` is present and `actions` are null or empty. ## Details ### Background In the current behavior of `AppBar`, if: - The `Scaffold` has a non-null `endDrawer`, and - The `AppBar.actions` is either `null` or an empty list `[]` Then Flutter **automatically inserts** a trailing menu icon (`Icons.menu`) into the `actions` list, which opens the `endDrawer`. ### New Behavior This PR introduces: ```dart final bool automaticallyImplyActions; // default: true ``` Developers can now control this behavior: - `automaticallyImplyActions: true` (default):\ The menu icon is automatically inserted when appropriate, as before. - `automaticallyImplyActions: false`:\ The `AppBar` will **not** add the automatic trailing menu icon, even if an `endDrawer` is present and `actions` are null or empty. ### All Possible Scenarios | `endDrawer` | `actions` | `automaticallyImplyActions` | Result | | ----------- | ----------------- | --------------------------- | ----------------------------------- | | ✅ present | `null` or `[]` | `true` (default) | Automatic menu icon is added | | ✅ present | `null` or `[]` | `false` | No menu icon is added | | ✅ present | `[customWidgets]` | `true` / `false` | Custom actions shown, no menu added | | ❌ absent | any value | any value | No menu icon is added | This provides predictable, developer-controlled behavior while maintaining backward compatibility. --- ## Use Case This change benefits developers who: - Want to **prevent automatic UI behaviors** when building custom app bars. - Need full control over the trailing icons without modifying internal logic. - Encounter issues where the menu icon appears unintentionally in minimal `AppBar` configurations. --- ## Default Behavior (No Breaking Change) - The default value is `true`, so existing applications are **not affected**. - The new behavior is **opt-in** by setting `automaticallyImplyActions: false`. --- ## 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]. - [ ] 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
…r#9670) flutter/flutter@afba7d7...20788c0 2025-07-24 [email protected] Roll Packages from 9c85e5e to 963550c (4 revisions) (flutter/flutter#172696) 2025-07-24 [email protected] Add missing deprecations to CupertinoDynamicColor. (flutter/flutter#171160) 2025-07-24 [email protected] Roll Dart SDK from a181fe571dc8 to 26dece893751 (2 revisions) (flutter/flutter#172683) 2025-07-24 [email protected] Migrate to null aware elements - Part 1 (flutter/flutter#172198) 2025-07-24 [email protected] licenses_cpp: implements extracting regions from matched text (flutter/flutter#172655) 2025-07-24 [email protected] Roll pub packages (flutter/flutter#172677) 2025-07-24 [email protected] Marks Mac_ios keyboard_hot_restart_ios to be unflaky (flutter/flutter#168053) 2025-07-24 [email protected] Roll Abseil and remove a workaround for a Fuchsia target that was unable to build Abseil (flutter/flutter#172665) 2025-07-24 [email protected] Add `automaticallyImplyActions` property to AppBar (flutter/flutter#171113) 2025-07-24 [email protected] fix: TabBar fontFamily inheritance with custom label styles (flutter/flutter#171699) 2025-07-23 [email protected] Marks Linux_mokey new_gallery__crane_perf to be unflaky (flutter/flutter#167633) 2025-07-23 [email protected] [android] Fix broken `--android-skip-build-dependency-validation` flag (flutter/flutter#172581) 2025-07-23 [email protected] Fix: Ensure Text widget locale is included in semantics language tag (flutter/flutter#172034) 2025-07-23 [email protected] [Web][a11y] Update selected chips semantics (flutter/flutter#172660) 2025-07-23 [email protected] Roll Skia from eea1c33fbe84 to 094ac350125f (29 revisions) (flutter/flutter#172664) 2025-07-23 [email protected] Marks Mac_arm64_ios imitation_game_flutter to be unflaky (flutter/flutter#168052) 2025-07-23 [email protected] Roll Dart SDK from a31774a3d049 to a181fe571dc8 (2 revisions) (flutter/flutter#172667) 2025-07-23 [email protected] Adapt xcresult parser for Xcode 16 changes (flutter/flutter#172596) 2025-07-23 [email protected] Update excluded_files to match the current output of the old license checker (flutter/flutter#172670) 2025-07-23 [email protected] Manual Roll of Dart SDK from da9e0299c120 to a31774a3d049 (flutter/flutter#172616) 2025-07-23 [email protected] [FGP] Small restructuring of Android Studio native flutter dependency support (flutter/flutter#172651) 2025-07-23 [email protected] revert: Replaces legacy licenses check with licenses_cpp (flutter/flutter#172568) 2025-07-23 [email protected] fix: size-exp naming (flutter/flutter#172647) 2025-07-23 [email protected] Roll Fuchsia Test Scripts from MnFlN7VWM_7h7EmBV... to BWj3yYC74ud58QhN0... (flutter/flutter#172646) 2025-07-23 [email protected] [DisplayList] implement shadow bounds without relying on Skia utilities (flutter/flutter#172572) 2025-07-23 [email protected] Update `dev/bots/post_process_docs.dart` to use `flutter.version.json` (flutter/flutter#172601) 2025-07-23 [email protected] Emit a warning on `--[no-]disable-dds`, preferring `--no-dds` (flutter/flutter#172595) 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] 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
## Summary - This PR adds a new boolean property `automaticallyImplyActions` to the `AppBar` widget. - It provides fine-grained control over whether an automatic menu icon (`Icons.menu`) is added when an `endDrawer` is present and `actions` are null or empty. ## Details ### Background In the current behavior of `AppBar`, if: - The `Scaffold` has a non-null `endDrawer`, and - The `AppBar.actions` is either `null` or an empty list `[]` Then Flutter **automatically inserts** a trailing menu icon (`Icons.menu`) into the `actions` list, which opens the `endDrawer`. ### New Behavior This PR introduces: ```dart final bool automaticallyImplyActions; // default: true ``` Developers can now control this behavior: - `automaticallyImplyActions: true` (default):\ The menu icon is automatically inserted when appropriate, as before. - `automaticallyImplyActions: false`:\ The `AppBar` will **not** add the automatic trailing menu icon, even if an `endDrawer` is present and `actions` are null or empty. ### All Possible Scenarios | `endDrawer` | `actions` | `automaticallyImplyActions` | Result | | ----------- | ----------------- | --------------------------- | ----------------------------------- | | ✅ present | `null` or `[]` | `true` (default) | Automatic menu icon is added | | ✅ present | `null` or `[]` | `false` | No menu icon is added | | ✅ present | `[customWidgets]` | `true` / `false` | Custom actions shown, no menu added | | ❌ absent | any value | any value | No menu icon is added | This provides predictable, developer-controlled behavior while maintaining backward compatibility. --- ## Use Case This change benefits developers who: - Want to **prevent automatic UI behaviors** when building custom app bars. - Need full control over the trailing icons without modifying internal logic. - Encounter issues where the menu icon appears unintentionally in minimal `AppBar` configurations. --- ## Default Behavior (No Breaking Change) - The default value is `true`, so existing applications are **not affected**. - The new behavior is **opt-in** by setting `automaticallyImplyActions: false`. --- ## 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]. - [ ] 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
## Summary - This PR adds a new boolean property `automaticallyImplyActions` to the `AppBar` widget. - It provides fine-grained control over whether an automatic menu icon (`Icons.menu`) is added when an `endDrawer` is present and `actions` are null or empty. ## Details ### Background In the current behavior of `AppBar`, if: - The `Scaffold` has a non-null `endDrawer`, and - The `AppBar.actions` is either `null` or an empty list `[]` Then Flutter **automatically inserts** a trailing menu icon (`Icons.menu`) into the `actions` list, which opens the `endDrawer`. ### New Behavior This PR introduces: ```dart final bool automaticallyImplyActions; // default: true ``` Developers can now control this behavior: - `automaticallyImplyActions: true` (default):\ The menu icon is automatically inserted when appropriate, as before. - `automaticallyImplyActions: false`:\ The `AppBar` will **not** add the automatic trailing menu icon, even if an `endDrawer` is present and `actions` are null or empty. ### All Possible Scenarios | `endDrawer` | `actions` | `automaticallyImplyActions` | Result | | ----------- | ----------------- | --------------------------- | ----------------------------------- | | ✅ present | `null` or `[]` | `true` (default) | Automatic menu icon is added | | ✅ present | `null` or `[]` | `false` | No menu icon is added | | ✅ present | `[customWidgets]` | `true` / `false` | Custom actions shown, no menu added | | ❌ absent | any value | any value | No menu icon is added | This provides predictable, developer-controlled behavior while maintaining backward compatibility. --- ## Use Case This change benefits developers who: - Want to **prevent automatic UI behaviors** when building custom app bars. - Need full control over the trailing icons without modifying internal logic. - Encounter issues where the menu icon appears unintentionally in minimal `AppBar` configurations. --- ## Default Behavior (No Breaking Change) - The default value is `true`, so existing applications are **not affected**. - The new behavior is **opt-in** by setting `automaticallyImplyActions: false`. --- ## 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]. - [ ] 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
## Summary - This PR adds a new boolean property `automaticallyImplyActions` to the `AppBar` widget. - It provides fine-grained control over whether an automatic menu icon (`Icons.menu`) is added when an `endDrawer` is present and `actions` are null or empty. ## Details ### Background In the current behavior of `AppBar`, if: - The `Scaffold` has a non-null `endDrawer`, and - The `AppBar.actions` is either `null` or an empty list `[]` Then Flutter **automatically inserts** a trailing menu icon (`Icons.menu`) into the `actions` list, which opens the `endDrawer`. ### New Behavior This PR introduces: ```dart final bool automaticallyImplyActions; // default: true ``` Developers can now control this behavior: - `automaticallyImplyActions: true` (default):\ The menu icon is automatically inserted when appropriate, as before. - `automaticallyImplyActions: false`:\ The `AppBar` will **not** add the automatic trailing menu icon, even if an `endDrawer` is present and `actions` are null or empty. ### All Possible Scenarios | `endDrawer` | `actions` | `automaticallyImplyActions` | Result | | ----------- | ----------------- | --------------------------- | ----------------------------------- | | ✅ present | `null` or `[]` | `true` (default) | Automatic menu icon is added | | ✅ present | `null` or `[]` | `false` | No menu icon is added | | ✅ present | `[customWidgets]` | `true` / `false` | Custom actions shown, no menu added | | ❌ absent | any value | any value | No menu icon is added | This provides predictable, developer-controlled behavior while maintaining backward compatibility. --- ## Use Case This change benefits developers who: - Want to **prevent automatic UI behaviors** when building custom app bars. - Need full control over the trailing icons without modifying internal logic. - Encounter issues where the menu icon appears unintentionally in minimal `AppBar` configurations. --- ## Default Behavior (No Breaking Change) - The default value is `true`, so existing applications are **not affected**. - The new behavior is **opt-in** by setting `automaticallyImplyActions: false`. --- ## 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]. - [ ] 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
## Summary - This PR adds a new boolean property `automaticallyImplyActions` to the `AppBar` widget. - It provides fine-grained control over whether an automatic menu icon (`Icons.menu`) is added when an `endDrawer` is present and `actions` are null or empty. ## Details ### Background In the current behavior of `AppBar`, if: - The `Scaffold` has a non-null `endDrawer`, and - The `AppBar.actions` is either `null` or an empty list `[]` Then Flutter **automatically inserts** a trailing menu icon (`Icons.menu`) into the `actions` list, which opens the `endDrawer`. ### New Behavior This PR introduces: ```dart final bool automaticallyImplyActions; // default: true ``` Developers can now control this behavior: - `automaticallyImplyActions: true` (default):\ The menu icon is automatically inserted when appropriate, as before. - `automaticallyImplyActions: false`:\ The `AppBar` will **not** add the automatic trailing menu icon, even if an `endDrawer` is present and `actions` are null or empty. ### All Possible Scenarios | `endDrawer` | `actions` | `automaticallyImplyActions` | Result | | ----------- | ----------------- | --------------------------- | ----------------------------------- | | ✅ present | `null` or `[]` | `true` (default) | Automatic menu icon is added | | ✅ present | `null` or `[]` | `false` | No menu icon is added | | ✅ present | `[customWidgets]` | `true` / `false` | Custom actions shown, no menu added | | ❌ absent | any value | any value | No menu icon is added | This provides predictable, developer-controlled behavior while maintaining backward compatibility. --- ## Use Case This change benefits developers who: - Want to **prevent automatic UI behaviors** when building custom app bars. - Need full control over the trailing icons without modifying internal logic. - Encounter issues where the menu icon appears unintentionally in minimal `AppBar` configurations. --- ## Default Behavior (No Breaking Change) - The default value is `true`, so existing applications are **not affected**. - The new behavior is **opt-in** by setting `automaticallyImplyActions: false`. --- ## 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]. - [ ] 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
Summary
automaticallyImplyActionsto theAppBarwidget.Icons.menu) is added when anendDraweris present andactionsare null or empty.Details
Background
In the current behavior of
AppBar, if:Scaffoldhas a non-nullendDrawer, andAppBar.actionsis eithernullor an empty list[]Then Flutter automatically inserts a trailing menu icon (
Icons.menu) into theactionslist, which opens theendDrawer.New Behavior
This PR introduces:
Developers can now control this behavior:
automaticallyImplyActions: true(default):The menu icon is automatically inserted when appropriate, as before.
automaticallyImplyActions: false:The
AppBarwill not add the automatic trailing menu icon, even if anendDraweris present andactionsare null or empty.All Possible Scenarios
endDraweractionsautomaticallyImplyActionsnullor[]true(default)nullor[]false[customWidgets]true/falseThis provides predictable, developer-controlled behavior while maintaining backward compatibility.
Use Case
This change benefits developers who:
AppBarconfigurations.Default Behavior (No Breaking Change)
true, so existing applications are not affected.automaticallyImplyActions: false.Pre-launch Checklist
///).