3055 Commits

Author SHA1 Message Date
Kostia Sokolovskyi
2c3db435a8
_RouterState should dispose created _RestorableRouteInformation. (#136556)
### Description
- Fixes https://github.com/flutter/flutter/issues/134205.

### Tests
- Removes ignoring the `_RestorableRouteInformation` leak from `cupertino/app_test.dart`;
- Removes ignoring the `_RestorableRouteInformation` leak from `material/app_test.dart`;
- Removes ignoring the `_RestorableRouteInformation` leak from `widgets/app_test.dart`;
- Removes ignoring the `_RestorableRouteInformation` leak from `widgets/route_notification_messages_test.dart`;
- Removes ignoring the `_RestorableRouteInformation` leak from `widgets/router_restoration_test.dart`;
- Updates `widgets/router_test.dart` to use `testWidgetsWithLeakTracking`.
2023-10-14 02:58:17 +00:00
Daniel Chevalier
ac095ed393
Changes WidgetInspector to use valuenotifier instead of a force rebuild for (#131634)
![](https://media.giphy.com/media/qriH9W51oLsL6/giphy.gif)
Fixes https://github.com/flutter/devtools/issues/6014

Change the forceRebuild behaviour of the WidgetInspector to use
ValueListenableBuilders instead. This should help resolve heavy rebuilds
when the widgetInspectorOverride value changes.
2023-10-13 17:07:57 -04:00
Polina Cherkasova
2ea541aca9
Stop skipping leaks in the test. (#136512) 2023-10-13 11:55:58 -07:00
xubaolin
3f722c1442
[SingleChildScrollView] Correct the offset pixels if it is out of range during layout (#136239)
Fixes https://github.com/flutter/flutter/issues/105733
FIxes https://github.com/flutter/flutter/issues/135865

The above two issues will not occur on the `ListView` widget, so after analyzing their differences, it was found that the `SingleChildScrollView` pixels were not corrected according to the content dimensions during layout.

### ListView correct the pixels codes
5dfd78c2e3/packages/flutter/lib/src/rendering/viewport.dart (L1462-L1465)

We should correct the pixels to prevent the physics ballistic simulations.

This change makes them have the same behavior.
2023-10-12 21:25:09 +00:00
Greg Spencer
22b0a62a0c
Allow TapRegion to consume tap events (#136305)
## Description

In order for `MenuAnchor` menus to be able to not pass on the taps that close their menus, `TapRegion` needed a way to consume them.  This change adds a flag to the `TapRegion`, `consumeOutsideTap` that will consume taps that occur outside of the region if the flag is set (it is false by default). The same flag is added to `MenuAnchor` to allow selecting the behavior for menus.

`TapRegion` consumes the tap event by registering with the gesture arena and immediately resolving the tap as accepted if any regions in a group have `consumeOutsideTap` set to true.

This PR also deprecates `MenuAnchor.anchorTapClosesMenu`, since it is a much more limited version of the same feature that only applied to the anchor itself, and even then only applied to closing the menu, not passing along the tap.  The same functionality can now be implemented by handling a tap on the anchor widget and checking to see if the menu is open before closing it.

## Related Issues
 - https://github.com/flutter/flutter/issues/135327

## Tests
 - Added tests for `TapRegion` to make sure taps are consumed properly.
2023-10-12 21:04:41 +00:00
Kostia Sokolovskyi
cc41e25f21
_RenderSnapshotWidget should dispose created OffsetLayer. (#136267) 2023-10-11 08:45:39 -07:00
Polina Cherkasova
ad05949971
Fix flakiness: finalize dropped gestures in tests to release resources, and update doc-comment. (#136136) 2023-10-10 18:11:23 -07:00
Valentin Vignal
b989428fa2
Add SizeTransition.fixedCrossAxisSizeFactor (#134659)
Fixes https://github.com/flutter/flutter/issues/134654
2023-10-11 00:53:34 +00:00
Greg Spencer
7e1d366a4d
Add key event handlers that happen before or after the focus traversal (#136280)
## Description

This adds a mechanism for listening to key events before or after focus traversal occurs.

It adds four methods to the public `FocusManager` API:

- `addEarlyKeyEventHandler` - Adds a handler that can handle events before they are given to the focus tree for handling.
- `removeEarlyKeyEventHandler` - Removes an early event handler.
- `addLateKeyEventHandler` - Adds a handler that can handle events if they have not been handled by anything in the focus tree.
- `removeLateKeyEventHandler` - Removes a late event handler.

This allows an app to get notified for a key anywhere, and prevent the focus tree from seeing that event if it handles it.

For the menu system, this allows it to eat an escape key press and close all the open menus.

## Related Issues
 - https://github.com/flutter/flutter/issues/135334

## Tests
 - Added tests for new functionality.
2023-10-10 23:16:25 +00:00
Polina Cherkasova
eec3f06090
TestClipPaintingContext should dispose ContainerLayer (#135949) 2023-10-10 08:19:50 -07:00
Hassan
e127f7191b
[web] Fix page up page down home end shortcut behavior on web (#135454)
We delegate page up / page down actions to the browser. However, we don't let the browser scroll the underlying `<textarea>` - the framework handles scrolling, so page up/down don't end up doing anything. Since the framework handles scrolling for text inputs and textareas, we should let it also handle the actions for `page up`, `page down`, `home`, `end`, and their modifiers. 

fixes https://github.com/flutter/flutter/issues/121867
2023-10-09 17:50:54 +00:00
chunhtai
ff73448f33
Reland "Adds a parent scope TraversalEdgeBehavior and fixes modal rou… (#134554)
…… (#134550)"

fixes https://github.com/flutter/flutter/issues/112567

This reverts commit 5900c4baa751aff8f05e820287a02b60cdd62dfa.

The internal test needs migration. cl/564746935

This is the same of original pr, no new change

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] 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].
- [ ] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#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/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-10-09 09:10:23 -07:00
LongCatIsLooong
ebe72d3f32
Call markNeedsPaint when adding overlayChild to Overlay (#135941)
Fixes https://github.com/flutter/flutter/issues/134656

`_skipMarkNeesLayout` was meant to only skip `markNeedsLayout` calls. Re-painting is still needed when a child gets added/removed from the `Overlay`.
2023-10-06 22:12:20 +00:00
Polina Cherkasova
f0970365ca
RenderEditable should dispose created layers. (#135942) 2023-10-06 12:30:20 -06:00
Kostia Sokolovskyi
cfe7afdc50
Fix memory leaks in WidgetInspector and WidgetInspectorService. (#135828) 2023-10-01 19:41:46 -07:00
Kostia Sokolovskyi
95eae5f967
Cover more test/widgets tests with leak tracking #12. (#135385) 2023-09-29 17:47:04 -07:00
Kostia Sokolovskyi
fdde24195f
DraggableScrollableController should dispatch creation in constructor. (#135423) 2023-09-29 17:45:35 -07:00
Kostia Sokolovskyi
a11b21dba8
ViewportOffset should dispatch creation in constructor. (#135420) 2023-09-29 14:08:39 -07:00
Kate Lovett
7c9feea835
Expose onAttach and onDetach in ScrollController subclasses (#135721)
Fixes https://github.com/flutter/flutter/issues/135574
This exposes the onAttach and onDetach callbacks of ScrollController in all of its subclasses.
2023-09-29 17:47:36 +00:00
Kate Lovett
3509a1dfb7
Remove assertions on getOffsetToReveal (#135634) 2023-09-28 18:01:46 -05:00
tauu
3b19c2e5d8
[web] fix: do not call onSubmitted of TextField when switching browser tabs on mobile web (#134870)
This PR fixes #134846. As discussed in the issue, the onSubmitted callback of a TextField is called when the browser switches tabs or is sent to the background if the flutter app is running in any mobile browser (desktop browsers are not affected). Furthermore there is no straight forward way to distinguish between onSubmitted being called because the user pressed the enter key and it being called because the user switched tabs. For example in a chat app this would cause a message to be sent when the user submits the text by pressing "send" on the virtual keyboard as well as when the user switches to another tab. The later action is likely not so much intended.

The next section explains what causes the bug and explains the proposed fix.

## Bug Analysis
The root cause for this behaviour is line 3494 in editable_text.dart: 0b540a87f1/packages/flutter/lib/src/widgets/editable_text.dart (L3487-L3499)
Only if the app is running on the web `_finalizeEditing` is called and this will then trigger the onSubmitted callback. If flutter is running on the web, there are only exactly 3 cases, in which the function is called. The following call trace analysis will describe why.
  - `connectionClosed()` is only called by in one location, `_handleTextInputInvocation` of the TextInput service.
367203b301/packages/flutter/lib/src/services/text_input.dart (L1896C12-L1899)
  - In particular it is only called if the TextInput service receives a 'TextInputClient.onConnectionClosed' message from the engine.
  - The only location where the web part of the engine send this message is the `onConnectionClosed` function of the TextEditingChannel.
cbda68a720/lib/web_ui/lib/src/engine/text_editing/text_editing.dart (L2242-L2254)
  - `onConnectionClosed` in turn is only called by the `sendTextConnectionClosedToFrameworkIfAny` function of `HybridTextEditing`.
cbda68a720/lib/web_ui/lib/src/engine/text_editing/text_editing.dart (L2340-L2345)

The function `sendTextConnectionClosedToFrameworkIfAny` is only called at 3 distinct locations of the web engine.

### 1. IOSTextEditingStrategy 
As described in the comment `sendTextConnectionClosedToFrameworkIfAny` is called if the browser is sent to the background or the tab is changed.
cbda68a720/lib/web_ui/lib/src/engine/text_editing/text_editing.dart (L1632-L1656)

### 2. AndroidTextEditingStrategy
Same situation as for iOS. `sendTextConnectionClosedToFrameworkIfAny` is also called if `windowHasFocus` is false, which is the case if the browser is sent to background or the tab is changed.
cbda68a720/lib/web_ui/lib/src/engine/text_editing/text_editing.dart (L1773-L1785)

### 3. TextInputFinishAutofillContext
This call seems to always happen when `finishAutofillContext` is triggered by the framework.
cbda68a720/lib/web_ui/lib/src/engine/text_editing/text_editing.dart (L2075-L2083)

## Proposed Fix
The fixed proposed and implemented by this PR is to simply delete the call to`_finalizeEditing` in the `connectionClosed` function of editable_text.dart.
0b540a87f1/packages/flutter/lib/src/widgets/editable_text.dart (L3487-L3499)

The reasoning for this being:
   * `_finalizeEditing` is only called in `connectionClosed` for the web engine.
   * As explained by the trace analysis above, the web engine only triggers this `_finalizeEditing` call in 3 cases.
   * In the 2 cases for IOSTextEditingStrategy and AndroidTextEditingStrategy the web engine triggering the call only causes the undesired behaviour reported in the issue.
   * In the third case for TextInputFinishAutofillContext, I can't see a good reason why this would require calling `_finalizeEditing` as it only instructs the platform to save the current values. Other platforms also don't have anything that would trigger onSubmitted being called, so it seems safe to remove it.
   * For other platforms the onConnectionClosed function was recently incorporated to only unfocus the TextField. So removing the call `_finalizeEditing` unifies the platform behaviour. See also
     https://github.com/flutter/flutter/pull/123929
     https://github.com/flutter/engine/pull/41500

*List which issues are fixed by this PR. You must list at least one issue.*
#134846

To simplify the evaluation, here are two versions of the minimal example given in the issue, build with the current master and with this PR applied:
current master: https://tauu.github.io/flutter-onsubmit-test/build/web-master/
current master + PR applied: https://tauu.github.io/flutter-onsubmit-test/build/web/
2023-09-28 16:43:04 +00:00
Renzo Olivares
21ad7122a1
Implement SelectionArea single click/tap gestures (#132682)
This change collapses the selection at the clicked/tapped location on single click down for desktop platforms, and on single click/tap up for mobile platforms to match native.

This is a change from how `SelectionArea` previously worked. Before this change a single click down would clear the selection. From observing a native browser it looks like when tapping on static text the selection is not cleared but collapsed. A user can still attain the selection from static text using the `window.getSelection` API.

https://jsfiddle.net/juepasn3/11/ You can try this demo out here to observe this behavior yourself. When clicking on static text the selection will change.

This change also allows `Paragraph.selections` to return selections that are collapsed. This for testing purposes to confirm where the selection has been collapsed.

Partially fixes: #129583
2023-09-28 01:42:16 +00:00
Kate Lovett
80fb7bd206
Support ensureVisible/showOnScreen/showInViewport for 2D Scrolling (#135182) 2023-09-27 16:57:24 -05:00
Kate Lovett
67d4a83116
Allow multiple ParentDataWidgets to write to ParentData (#133581)
Fixes https://github.com/flutter/flutter/issues/133089

This allows more than one ParentDataWidget to write to the ParentData of a child render object. Previously only one was allowed. There are some rules though:
1. Only one of a given type of `ParentDataWidget` can write to the `ParentData` of a given child.
  a. For example, 2 `Positioned` widgets wrapping a child of a `Stack` would not be allowed, as only one of type `Positioned` can contribute data.

2. The type of `ParentData` **must** be compatible with all of the `ParentDataWidget`s that want to contribute data.
  a. For example, `TwoDimensionalViewportParentData` mixes in the `KeepAliveParentDataMixin`. So the `ParentData` of a given child would be compatible with the `KeepAlive` `ParentDataWidget`, as well as another `ParentDataWidget` that writes `TwoDimensionalViewportParentData` (or a subclass of `TwoDimensionalViewportParentData` - This was the motivation for this change, where a `ParentDataWidget` is being used in `TableView` with the parent data type being a subclass of `TwoDimensionalViewportParentData`.)
2023-09-26 22:38:18 +00:00
Renzo Olivares
d81c8aa88b
SelectionArea long press selection overlay behavior should match native (#133967)
During a long press, on native iOS the context menu does not show until the long press has ended. The handles are shown immediately when the long press begins. This is true for static and editable text.

For static text on Android, the context menu appears when the long press is initiated, but the handles do not appear until the long press has ended. For editable text on Android, the context menu does not appear until the long press ended, and the handles also do not appear until the end.

For both platforms in editable/static contexts the context menu does not show while doing a long press drag.

I think the behavior where the context menu is not shown until the long press ends makes the most sense even though Android varies in this depending on the context. The user is not able to react to the context menu until the long press has ended.

Other details:
On a windows touch screen device the context menu does not show up until the long press ends in editable/static text contexts. On a long press hold it selects the word on drag start as well as popping up the selection handles (static text).
2023-09-26 22:06:15 +00:00
Edgar Jan
79caa8373c
Fix and Test Conditional Validator Behavior in FormField (#132714)
In the FormField widget, if a validator is initially set (and validation fails), then subsequently the validator is set to null, the form incorrectly retains its error state. This is not expected behavior as removing the validator should clear any validation errors.
2023-09-25 19:17:07 +00:00
Polina Cherkasova
49f1a6bb96
Fix failing test at master. (#135394) 2023-09-24 18:20:02 -07:00
Polina Cherkasova
49e16867a3
TabController should dispatch creation in constructor. (#133952) 2023-09-22 15:27:05 -07:00
Kostia Sokolovskyi
9d42ad84ee
Fix memory leak in NestedScrollViewState. (#135248) 2023-09-21 18:20:23 -07:00
Kostia Sokolovskyi
ffecedbca4
Cover more test/widgets tests with leak tracking #11 (#135231) 2023-09-21 16:30:32 -07:00
Polina Cherkasova
77718845dd
Handle breaking changes in leak_tracker. (#135185) 2023-09-21 10:06:21 -07:00
Kostia Sokolovskyi
04854e8aff
Fix memory leak in _SelectableTextState (#135049) 2023-09-20 16:43:44 -07:00
Kostia Sokolovskyi
e6d160a5c7
Cover more test/widgets tests with leak tracking #7 (#134943) 2023-09-20 13:27:29 -07:00
Michael Goderbauer
b0a90aee17
Enable strict-inference (#135043)
Avoids that dynamic accidentally sneaks in, see https://dart.dev/tools/analysis#enabling-additional-type-checks
2023-09-20 19:59:08 +00:00
Kostia Sokolovskyi
96a4ae9dc5
Cover more test/widgets tests with leak tracking #10 (#135143) 2023-09-20 12:29:33 -07:00
Kostia Sokolovskyi
98ebab58ee
Cover more test/widgets tests with leak tracking #8 (#135045) 2023-09-20 07:34:41 -07:00
Kostia Sokolovskyi
c3db020993
Cover more test/widgets tests with leak tracking #9 (#135054) 2023-09-20 07:34:23 -07:00
Polina Cherkasova
ab66f55728
Reland Resolve breaking change of adding a method to ChangeNotifier. (#134983) 2023-09-18 20:31:54 -07:00
Zachary Anderson
a9183f696c
Revert "Resolve breaking change of adding a method to ChangeNotifier." (#134978)
Reverts flutter/flutter#134953

Several failures on CI
2023-09-18 23:04:06 +00:00
Polina Cherkasova
5c6ef59b90
Resolve breaking change of adding a method to ChangeNotifier. (#134953) 2023-09-18 15:33:06 -07:00
chunhtai
f2050e8a10
Fixes focus traversal crash if the current node can't request focus (#134954)
fixes https://github.com/flutter/flutter/issues/134854

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] 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].
- [ ] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#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/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-09-18 15:17:52 -07:00
Michael Goderbauer
da0f9a997a
Enable private field promotion for framework (#134473)
New feature in upcoming Dart 3.2. See https://github.com/dart-lang/language/issues/2020. Feature is enabled by bumping the min SDK version to 3.2.

Part of https://github.com/flutter/flutter/issues/134476.
2023-09-18 20:51:09 +00:00
Kostia Sokolovskyi
2396a417e3
Cover more test/widgets tests with leak tracking #6 (#134884) 2023-09-18 13:46:29 -07:00
Polina Cherkasova
658710b6f9
Cover more tests with leak tracking. (#134805) 2023-09-18 13:45:38 -07:00
Kostia Sokolovskyi
56cbf3e1d9
Cover more test/widgets tests with leak tracking #5 (#134869) 2023-09-18 13:44:55 -07:00
Xilai Zhang
6425a3b431
[flutter roll] Revert "LinkedText (Linkify)" (#134955)
Reverts flutter/flutter#125927

context: b/300804374

Looks like a g3 fix might involve changing the names of widget on the customer app, and I am not sure if that would be the right approach forward. Putting up a revert to be safe for now.
2023-09-18 19:49:10 +00:00
Kostia Sokolovskyi
9dd3e1e6fc
Fix memory leak in _DarwinViewState. (#134938) 2023-09-18 11:39:01 -07:00
Kostia Sokolovskyi
09acfe6341
Fix memory leak in ListWheelScrollView (#134732) 2023-09-14 20:52:22 -07:00
chunhtai
0e521942a3
Allows page removal that contains Localhistoryentry (#134757)
fixes https://github.com/flutter/flutter/issues/97836
fixes https://github.com/flutter/flutter/issues/134752
fixes https://github.com/flutter/flutter/issues/118645
2023-09-14 21:00:55 +00:00
Kostia Sokolovskyi
ff10c52ad6
Cover more test/widgets tests with leak tracking #3 (#134576) 2023-09-14 12:26:41 -07:00