Fixes https://github.com/flutter/flutter/issues/163576
Fixes https://github.com/flutter/flutter/issues/175184
This PR refactored the grafting part on `OverlayPortal`. Originally, the
semantics tree of `OverlayPortal` was constructed/grafted in render
object phase to make sure the correctness of the traversal order.
However this resulted wrong hit-test order and the issue surfaced on
web. With the fact that on web we are not able to graft/correct hit-test
order tree, this PR:
* Reverts the original grafting of the `OverlayPortal` so the hit-test
order is always correct.
* Then, we adds the grafting and updates the traversal order when we
send `childrenInTraversalOrder` to engine.
* Updating `childrenInTraversalOrder` causes it have different length
from the length of `childrenInHitTestOrder` and wrong hit-test transform
of the `OverlayPortal` children because when the transform is
calculated, it assumes a correct traversal order. To fix these issues,
this PR also:
* recalculates the transform for `OverlayPortal` children.
* adds `hitTestTransform` property and pass it to Android engine.
* skip grafting for web because it assumes the same length of
`childrenInTraversalOrder` and `childrenInHitTestOrder`.
* added grafting by using `ARIA-owns` in web engine to fix the traversal
order.
## 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.
## Description
This PR tweaks the selection logic added in
https://github.com/flutter/flutter/pull/157399.
Before this PR (and since
https://github.com/flutter/flutter/pull/157399) when the app resumed
while a TextField was selected the selection of the TextField is
maintained. This is the right behavior for the currently focused
TextField. But when there are several TextFields, after the app resumed
and the user move the focus to a another TextField, the behavior should
be to select all the content of the newly focused TextField. To achieve
this the `_justResumed`flag added in
https://github.com/flutter/flutter/pull/157399 should be reset as soon
as the focus move as it is needed only for the current focused TextField
to restore its selection just after the app resumed.
## Related Issue
Fixes [Pressing tab does select all content when app is resumed for
TextFields which were not
focused](https://github.com/flutter/flutter/issues/177650)
## Tests
- Adds 1 test
## Description
This PR changes `TextButton.icon` to avoid building a different widget.
When a different widget is created the whole subtree is recreated which
leads to various issues (Focus and A11y issues for instance).
The change is similar to https://github.com/flutter/flutter/pull/175810
which fixed the exact same problem for `OutlinedButton.icon`.
## Related Issue
Fixes [TextButton.icon breaks focus traversal and ink effect when
toggling icon](https://github.com/flutter/flutter/issues/173944)
## Tests
- Adds 1 test
---------
Co-authored-by: chunhtai <47866232+chunhtai@users.noreply.github.com>
This makes it possible for applications to set a FontWeight and get the
expected result for both variable fonts and fonts that provide separate
assets for each weight.
See https://github.com/flutter/flutter/issues/148026
Implements engine-side declarative pointer event handling for semantics.
Framework-side to be implemented in next PR.
Fixesflutter/flutter#149001.
**Before change**
https://dialog-dismiss-before.web.app/
Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog being dismissed.
**After change**
https://dialog-dimiss-after.web.app/
Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog not dismissed.
Changes:
* Move OpenUpwardsPageTransitionsBuilder from
`material/page_transitions_theme.dart` to
`widget/page_transitions_builder.dart`
* Replace `Colors.black` with `const Color(0xFF000000)` in
_OpenUpwardsPageTransition until framework colors are available(if we
add).
part of: https://github.com/flutter/flutter/issues/172929
## 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.
## Description
This PR replaces global `ThemeData.inputDecorationTheme` usage in
`InputDatePickerFormField` with `InputDecorationTheme.of ` which returns
the ambient `InputDecorationTheme`.
It is a follow up to https://github.com/flutter/flutter/pull/168981
which introduces `InputDecorationTheme.of `.
## Related Issue
Fixes [InputDatePickerFormField does not inherit local
InputDecorationTheme](https://github.com/flutter/flutter/issues/177088)
## Tests
- Adds 1 test
Fixes https://github.com/flutter/flutter/issues/169712
## 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.
- [ ] 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.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->
Fix: #176362
Issue provided reproducible code related to exception being thrown when
removing all items in an `AnimatedList` when some of the item were
already being removed but had a long animation duration.
In this PR: The `removeAllItems` method now correctly calculates the
range of items to remove, excluding those already undergoing a removal
animation. This prevents an assert from triggering when `removeAllItems`
is called while other items are still being removed.
<details open>
<summary> Video example after fix </summary>
https://github.com/user-attachments/assets/c7351702-b829-4e35-9978-b95f9f3ae8cd
</details>
<details open>
<summary> Updated reproducible code </summary>
```
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(debugShowCheckedModeBanner: false, home: AnimatedListExample());
}
}
class AnimatedListExample extends StatefulWidget {
const AnimatedListExample({super.key});
@override
State<AnimatedListExample> createState() => _AnimatedListExampleState();
}
class _AnimatedListExampleState extends State<AnimatedListExample> {
final GlobalKey<AnimatedListState> _listKey = GlobalKey<AnimatedListState>();
final List<int> _items = List<int>.generate(10, (int index) => index);
void _removeItem(int index) {
final int removedItem = _items[index];
_listKey.currentState?.removeItem(
index,
(BuildContext context, Animation<double> animation) => SizeTransition(
sizeFactor: animation,
child: _buildItem(removedItem, animation, isRemoved: true),
),
// 👇 Long delay so you can press "Remove All" while it’s still animating
duration: const Duration(seconds: 10),
);
_items.removeAt(index);
}
void _addItem() {
final int addingItem = _items.length;
_listKey.currentState?.insertItem(addingItem, duration: const Duration(seconds: 3));
_items.add(addingItem);
}
void _removeAll() {
_listKey.currentState?.removeAllItems((BuildContext context, Animation<double> animation) {
return SizeTransition(
sizeFactor: animation,
child: Container(
color: Colors.red[100],
child: const ListTile(title: Text('Removing...')),
),
);
}, duration: const Duration(seconds: 2));
_items.clear();
}
Widget _buildItem(int item, Animation<double> animation, {bool isRemoved = false}) {
return SizeTransition(
sizeFactor: animation,
child: Card(
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
child: ListTile(
title: Text('Item $item'),
trailing: !isRemoved
? IconButton(
icon: const Icon(Icons.delete, color: Colors.red),
onPressed: () {
final int index = _items.indexOf(item);
if (index != -1) {
_removeItem(index);
}
},
)
: null,
),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('AnimatedList Example'),
actions: <Widget>[
TextButton(onPressed: _addItem, child: const Text('Add')),
TextButton(
onPressed: _items.isNotEmpty ? _removeAll : null,
child: const Text('Clear list'),
),
],
),
body: AnimatedList(
key: _listKey,
initialItemCount: _items.length,
itemBuilder: (BuildContext context, int index, Animation<double> animation) {
return _buildItem(_items[index], animation);
},
),
);
}
}
```
</details>
## 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 `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.
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](https://developers.google.com/gemini-code-assist/docs/review-github-code).
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.
<!-- 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: chunhtai <47866232+chunhtai@users.noreply.github.com>
Fix#175759
The fix involves using the same logic for cache calculation on
RenderViewport.
## 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.
## Description
This PR replaces global `ThemeData.inputDecorationTheme` usage in
`DateRangePickerDialog` with `InputDecorationTheme.of ` which returns
the ambient `InputDecorationTheme`.
It is a follow up to https://github.com/flutter/flutter/pull/168981
which introduces `InputDecorationTheme.of `.
## Related Issue
Fixes [DateRangePickerDialog does not inherit local
InputDecorationTheme](https://github.com/flutter/flutter/issues/177083)
## Tests
- Adds 1 test
This is my attempt to handle
https://github.com/flutter/flutter/issues/6537 for the
CupertinoDesktopTextSelectionToolbar UI control.
---------
Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
This is my attempt to handle #6537 for the BottomSheet UI control.
---------
Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
This is my attempt to handle
https://github.com/flutter/flutter/issues/6537 for SimpleDialog and
SimpleDialogOption UI controls.
---------
Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
## Description
This PR adds `DropdownMenu.decorationBuilder`.
The goal is to make `DropdownMenu` more flexible.
Before this PR, several fields are used by `DropdownMenu` to create an
inner `InputDecoration`. This approach has several limitations:
- `InputDecoration` has more fields that the ones that are exposed
- `DropdownMenu` makes some choices that can't be change. Especially, it
creates an IconButton (with hardcoded padding) which is passed to
`InputDecoration.suffixIcon`. This inner `IconButton` introduces some
difficulty related to focus management and UI customization.
The new `DropdownMenu.decorationBuilder` property offers users a way to
take control on the inner `InputDecoration` in a non-breaking way.
In a future PR, this property will help replacing the default
`IconButton`.
Currently users can replace the `IconButton` using this code sample:
<details><summary>DropdownMenu without IconButton</summary>
```dart
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
MyApp({super.key});
final List<DropdownMenuEntry<String>> menuEntries = [
"Red",
"Green",
"Blue",
].map((t) => DropdownMenuEntry<String>(label: t, value: t)).toList();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: SizedBox(
width: 220,
child: DropdownMenu<String>(
expandedInsets: EdgeInsets.zero,
requestFocusOnTap: true,
dropdownMenuEntries: menuEntries,
decorationBuilder: (context, controller) {
return InputDecoration(
labelText: 'Label text',
helperText: 'Select a color or enter one',
suffixIcon: controller.isOpen
? const Icon(Icons.arrow_drop_up)
: const Icon(Icons.arrow_drop_down),
);
},
),
),
),
),
);
}
}
```
</details>
## Related Issue
Fixes [DropDownMenu secondary trailing
widget](https://github.com/flutter/flutter/issues/175847)
Will help for [Make DropdownMenu's trailing icon not focusable by
default](https://github.com/flutter/flutter/issues/174096)
## Related discussions
https://github.com/flutter/flutter/issues/175847#issuecomment-3330098375https://github.com/flutter/flutter/pull/175558#discussion_r2380227394
## Tests
- Adds 7 tests.
This change updates the default context menu when using
`SelectionArea`/`SelectableRegion` on Android or iOS web.
Previously: the native browser menu would be used.
After this change: the flutter rendered context menu is used.
Fixes https://github.com/flutter/flutter/issues/151468
- [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.
---------
Co-authored-by: Renzo Olivares <roliv@google.com>
This PR updates selectable region so it dismisses the selection when a
tap happens outside of it. This is done through the use of `TapRegion`
and it's `onTapOutside` callback.
https://github.com/user-attachments/assets/d5678c85-9d04-4c9c-af16-9a09a001c228
## 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.
---------
Co-authored-by: Renzo Olivares <roliv@google.com>
This PR adds support for configuring smartQuotesType and smartDashesType
in SearchAnchor. These values are passed down to the inner TextField,
allowing developers to control smart quotes and smart dashes behavior
consistently when using SearchAnchor
fixes: #174509
## 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.
This change fixes an issue where the flutter rendered menu would show up
when ending a drag on a selection handle, even when the web context menu
was enabled. This led to issues where both context menus would show up
leading to a unfavorable experience.
Fixes#175114
## 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.
---------
Co-authored-by: Renzo Olivares <roliv@google.com>
Changes:
* Move FadeUpwardsPageTransitionsBuilder from
`material/page_transitions_theme.dart` to
`widget/page_transitions_builder.dart`
part of: https://github.com/flutter/flutter/issues/172929
## 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.