10453 Commits

Author SHA1 Message Date
Michael Goderbauer
9a726e8542
Remove obsolete work around for shadow drawing (#131066)
Fixes https://github.com/flutter/flutter/issues/130737.
2023-07-21 22:59:01 +00:00
Pierre-Louis
0919fb86f1
Improve handling of certain icons in RTL (#130979)
Fixes https://github.com/flutter/flutter/issues/130978 

## 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] 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-07-21 19:07:39 +02:00
hangyu
aafdbc6d12
Add tests for navigation_drawer_theme_test.dart (#130465)
fixes: https://github.com/flutter/flutter/issues/129618
2023-07-21 10:38:54 +00:00
Greg Spencer
e4a39fa2ed
Add applyFocusChangeIfNeeded, have menus restore focus before activating (#130536)
## Description

This modifies the `MenuAnchor` `onPressed` activation to delay until after the current frame is built, and resolve any focus changes before it invokes the `onPressed`, so that actions that operate on the `primaryFocus` can have a chance of working on the focused item they were meant to work on.

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

## Tests
 - No tests yet (hence draft still)
2023-07-20 22:11:20 +00:00
Ian Hickson
14c2153b31
Trivial grammar and wrapping fix for docs (#130955) 2023-07-20 20:37:04 +00:00
Hans Muller
93f7dc321d
Updated the ThemeData API example (#130954) 2023-07-20 13:12:34 -07:00
Taha Tesser
f92637d7c4
Fix chip delete button tap target spilling into the label. (#130896)
fixes [Chip's delete button tap target is too big](https://github.com/flutter/flutter/issues/129986)

### Description 

This PR fixes the issue where the chip delete button is tappable within the label. 

### Code sample

<details> 
<summary>expand to view the code sample</summary> 

```dart
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(useMaterial3: true),
      home: const Example(),
    );
  }
}

class Example extends StatelessWidget {
  const Example({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Sample'),
      ),
      body: Center(
        child: Chip(
          label: const Text('Really Long Label'),
          onDeleted: () {},
        ),
      ),
    );
  }
}
``` 
	
</details>

### Before

https://github.com/flutter/flutter/assets/48603081/14b369c5-c740-4dfc-a512-779bd3a1a46b

### After

https://github.com/flutter/flutter/assets/48603081/08c6e232-0237-4ab2-9829-66ee8e5cead2
2023-07-20 09:25:24 +00:00
Bruno Leroux
0aba94f461
Fix IconButton leaks its internal MaterialStatesController (#130720)
## Description

This PR adds a call to dispose the internal `MaterialStatesController` instantiated by `_SelectableIconButtonState`.

I found this memory leak while working on M2/M3 test update for `about_test.dart`. This memory leak only happens when using M3 because `IconButton` relies on `_SelectableIconButton` only when useMaterial3 is true:

3a1190a5a8/packages/flutter/lib/src/material/icon_button.dart (L671-L721)

## Related Issue

Fixes https://github.com/flutter/flutter/issues/130708

## Tests

Adds 1 test.
2023-07-20 07:54:23 +00:00
Ian Hickson
a1b1386392
More documentation for MediaQuery and friends (#130509)
Fixes https://github.com/flutter/flutter/issues/11697
2023-07-20 04:35:11 +00:00
Ian Hickson
3a1300e0c4
Automatically create the layer when setting hints in PaintingContext (#130364)
Fixes https://github.com/flutter/flutter/issues/92722
2023-07-20 03:28:57 +00:00
Ian Hickson
17b732bb6d
Further clarify Stack documentation on overflowing (#130776)
Fixes #75731
2023-07-20 01:35:34 +00:00
chunhtai
4763be745d
Can traverse if current focused node skips traversal (#130812)
Currently if the focus is on a focusnode that `skipTraversal = true`, the tab won't be able to traverse focus out of the node.

this pr fixes it
2023-07-20 01:01:01 +00:00
Ian Hickson
9c8ee4fab6
Document that you can't change initialRoute usefully (#130450)
Fixes https://github.com/flutter/flutter/issues/12454
2023-07-20 00:41:51 +00:00
Ian Hickson
10f464895d
Add docs to Route.maintainState (#130638)
Fixes https://github.com/flutter/flutter/issues/44836
2023-07-19 22:53:54 +00:00
Greg Spencer
258382c594
Add menu dismiss localization (#128613)
## Description

Modifies the semantic label for popup and context menus to be "Dismiss menu" instead of just "Dismiss".

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

## Tests
 - Updated tests
2023-07-19 22:48:40 +00:00
Ian Hickson
07cdf37ca3
Add implementation advice to debugTypicalAncestorWidgetClass (#130530)
Fixes https://github.com/flutter/flutter/issues/56500
2023-07-19 22:47:43 +00:00
Pierre-Louis
0830a362d5
Add support for M3 motion (#129942)
## Description

This adds support for M3 easing and duration tokens.

This PR includes these changes:
* Generation of duration and easing constants, in `Durations` and
`Easing`, respectively (`Curves` is already taken in the `animation`
library)
* Add 3 Dart fixes

Once this is merged, I'll migrate packages/plugins/customers and then
uncomment the deprecation notices for the 3 M2 curves, all of which have
1:1 replacements.

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

## Tests
 - Added Dart fix tests

## 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] 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-07-19 22:07:59 +02:00
Greg Price
f003911967
Fix contradictory advice in "detach" docs; cut redundancy in "attach" (#130688)
Fixes #115525.

On [AbstractNode.detach] and its two progeny [RenderNode.detach]
and [Layer.detach], the docs said both to call the inherited method
before detaching children, and to end by doing so.  The former
advice is what's enforced by an assertion in the base implementation,
so cut out the other.

The corresponding [attach] methods redundantly said twice to
call the inherited method first, so cut the redundancy.
Leave in place the version more recently added (in #76021), because
that PR shows the old version must have been easy to overlook.
2023-07-19 16:36:08 +00:00
Tomasz Gucio
e4e9dde4ed
Move TapAndDragGestureRecognizer code under gestures (#119508) 2023-07-19 11:48:01 +02:00
Ian Hickson
d21109220b
Catch errors in loadStructuredData (#130748)
Fixes https://github.com/flutter/flutter/issues/42390
2023-07-18 23:02:56 +00:00
fzyzcjy
2d753a621e
Fix super tiny space formatting (hope we have auto formatter in the future) (#127479)
Just fix a space... I do hope we can have the auto formatter enabled in the future!
2023-07-18 23:01:13 +00:00
Hans Muller
433f93560a
Updated ThemeData.useMaterial3 API doc, default is true (#130764)
Fixes https://github.com/flutter/flutter/issues/130761
2023-07-18 11:22:02 -07:00
Greg Spencer
8b768de18f
Add lint check to make sure samples are linked and have tests (#130523)
## Description

This adds a checker that will check all of the API docs examples to make sure that they are linked from at least one source file in the packages.

It also checks to make sure that all of the examples have an associated test. Since there are a large number that don't have tests at the moment, there is also a large exception list that can be burned down (burn down list is in https://github.com/flutter/flutter/issues/130459).

Because there are missing links currently, this PR will only pass after https://github.com/flutter/flutter/pull/130521 is merged.

## Related Issues

- https://github.com/flutter/flutter/issues/129956
- https://github.com/flutter/flutter/issues/130459

## Tests

- Added test for the checker.
2023-07-18 15:26:09 +00:00
yaakovschectman
203ef6f7a3
Extract common functionality of iOS platformviews into superclasses (#128716)
Move most functionality of `UiKitView` and its supporting classes into
superclasses named `DarwinPlatformView`, etc., and create trivial or
near-trivial subclasses with the same names as the old classes.

I am currently awaiting approval for a macOS workstation that would
allow me to run the iOS/macOS tests and make sure all existing
functionality is preserved by this refactor. I can ensure that tests
will pass, but doing so may need to wait for a while.

Addresses [Add
AppKitView](https://github.com/flutter/flutter/issues/128519)

## 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].
- [ ] 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].
- [x] 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

---------

Co-authored-by: Loïc Sharma <737941+loic-sharma@users.noreply.github.com>
Co-authored-by: Michael Goderbauer <goderbauer@google.com>
Co-authored-by: Chris Bracken <chris@bracken.jp>
2023-07-18 10:06:52 -04:00
Taha Tesser
fa6754d362
Fix iconTheme in AppBar doesn't apply custom Colors.white in the dark mode for M3 (#130574)
fixes [[Material3] AppBar does not respect `foregroundColor` or `iconTheme` for leading and actions in some cases](https://github.com/flutter/flutter/issues/130485)

### Description

- Fix `Colors.white` not applied in dark mode
- Add regression tests
- make `iconStyle` private for consistency

### Before
![Screenshot 2023-07-14 at 18 40 58](https://github.com/flutter/flutter/assets/48603081/a6caffd6-d9a1-407a-aea7-c30047bfe7c7)

### After
![Screenshot 2023-07-14 at 18 41 04](https://github.com/flutter/flutter/assets/48603081/f864da7a-2ff8-46a4-8927-591e50050502)
2023-07-18 08:26:09 +00:00
Ian Hickson
e12d31ad75
Document stack's clipping behaviour better (#130749)
Fixes https://github.com/flutter/flutter/issues/40216
2023-07-18 03:36:18 +00:00
LongCatIsLooong
fe7d01ffab
Prevent InputDecorator from supplying its descendants with non-normalized constraints (#130460)
Fixes https://github.com/flutter/flutter/issues/129611
2023-07-17 23:35:20 +00:00
Greg Price
1937ae6539
Make AbstractNode-derived docs more specific on RenderObject et al. (#130689)
These methods and/or their docs were recently copied (in #128467 and #128973) from their classes' former shared base class AbstractNode. Their wording was fittingly abstract there, but that abstraction is a bit puzzling for a reader finding them on these more concrete classes and not aware of the AbstractNode history.  So make them more concrete, in similar terms to the other methods around them.

Also copy some useful points between corresponding methods on different classes (like that the parent of the root is null), and try to clean up the prose on [RenderObject.depth].

We focus on the more outward-facing parts of the API, letting methods like `redepthChildren` continue to talk generically about "nodes".
2023-07-17 18:20:27 +00:00
LongCatIsLooong
b2e22d3558
Replaces textScaleFactor with TextScaler (#128522)
Deprecate `textScaleFactor` in favor of `textScaler`, in preparation for Android 14 [Non-linear font scaling to 200%](https://developer.android.com/about/versions/14/features#non-linear-font-scaling). The `TextScaler` class can be moved to `dart:ui` in the future, if we decide to use the Android platform API or AndroidX to get the scaling curve instead of hard coding the curve in the framework.

I haven't put the Flutter version in the deprecation message so the analyzer checks are failing. Will do so after I finish the migration guide.

**Why `TextScaler.textScaleFactor`**
The author of a `TextScaler` subclass should provide a fallback `textScaleFactor`. By making `TextScaler` also contain the `textScaleFactor` information it also makes it easier to migrate: if a widget overrides `MediaQueryData.textScaler` in the tree, for unmigrated widgets in the subtree it would also have to override `MediaQueryData.textScaleFactor`, and that makes it difficult to remove `MediaQueryData.textScaleFactor` in the future.

## A full list of affected APIs in this PR

Deprecated: The method/getter/setter/argument is annotated with a `@Deprecated()` annotation in this PR, and the caller should replace it with `textScaler` instead. Unless otherwise specified there will be a Flutter fix available to help with migration but it's still recommended to migrate case-by-case.
**Replaced**:  The method this `textScaleFactor` argument belongs to is rarely called directly by user code and is not overridden by any of the registered custom tests, so the argument is directly replaced by `TextScaler`.
**To Be Deprecated**:  The method/getter/setter/argument can't be deprecated in this PR because a registered customer test depends on it and a Flutter fix isn't available (or the test was run without applying flutter fixes first). This method/getter/setter/argument will be deprecated in a followup PR once the registered test is migrated.

### `Painting` Library

| Affected API | State of `textScaleFactor` | Comment | 
| --- | --- | --- |
| `InlineSpan.build({ double textScaleFactor = 1.0 })` argument | **Replaced** | | 
| `TextStyle.getParagraphStyle({ double TextScaleFactor = 1.0 })` argument | **Replaced** | |
| `TextStyle.getTextStyle({ double TextScaleFactor = 1.0 })`  argument| Deprecated | Can't replace: c47fd38dca/super_editor/lib/src/infrastructure/super_textfield/desktop/desktop_textfield.dart (L1903-L1905)|
| `TextPainter({ double TextScaleFactor = 1.0 })` constructor argument | Deprecated | |
| `TextPainter.textScaleFactor` getter and setter | Deprecated | No Flutter Fix, not expressible yet |
| `TextPainter.computeWidth({ double TextScaleFactor = 1.0 })` argument | Deprecated | |
| `TextPainter.computeMaxIntrinsicWidth({ double TextScaleFactor = 1.0 })` argument | Deprecated | |

### `Rendering` Library

| Affected API | State of `textScaleFactor` | Comment | 
| --- | --- | --- |
| `RenderEditable({ double TextScaleFactor = 1.0 })` constructor argument | Deprecated | |
| `RenderEditable.textScaleFactor` getter and setter | Deprecated | No Flutter Fix, not expressible yet |
| `RenderParagraph({ double TextScaleFactor = 1.0 })` constructor argument | Deprecated | |
| `RenderParagraph.textScaleFactor` getter and setter | Deprecated | No Flutter Fix, not expressible yet |

### `Widgets` Library

| Affected API | State of `textScaleFactor` | Comment | 
| --- | --- | --- |
| `MediaQueryData({ double TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | cd7b93532e/packages/flutter_markdown/test/text_scale_factor_test.dart (LL39C21-L39C35) |
| `MediaQueryData.textScaleFactor` getter | Deprecated | |
| `MediaQueryData.copyWith({ double? TextScaleFactor })` argument | Deprecated | |
| `MediaQuery.maybeTextScaleFactorOf(BuildContext context)` static method | Deprecated | No Flutter Fix, not expressible yet  |
| `MediaQuery.textScaleFactorOf(BuildContext context)` static method | **To Be Deprecated** | cd7b93532e/packages/flutter_markdown/lib/src/_functions_io.dart (L68-L70), No Flutter Fix, not expressible yet |
| `RichText({ double TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | cd7b93532e/packages/flutter_markdown/lib/src/builder.dart (L829-L843) |
| `RichText.textScaleFactor` getter | **To Be Deprecated** | A constructor argument can't be deprecated right away|
| `Text({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | 914d120da1/packages/rfw/lib/src/flutter/core_widgets.dart (L647) , No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `Text.rich({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | The default constructor has an argument that can't be deprecated right away. No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `Text.textScaleFactor` getter | **To Be Deprecated** | A constructor argument can't be deprecated right away |
| `EditableText({ double? TextScaleFactor = 1.0 })` constructor argument | Deprecated | No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `EditableText.textScaleFactor` getter | Deprecated | |

### `Material` Library

| Affected API | State of `textScaleFactor` | Comment | 
| --- | --- | --- |
| `SelectableText({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | cd7b93532e/packages/flutter_markdown/lib/src/builder.dart (L829-L843), No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `SelectableText.rich({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | The default constructor has an argument that can't be deprecated right away. No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `SelectableText.textScaleFactor` getter | **To Be Deprecated** | A constructor argument can't be deprecated right away |

A lot of material widgets (`Slider`, `RangeSlider`, `TimePicker`, and different types of buttons) also change their layout based on `textScaleFactor`. These need to be handled in a case-by-case fashion and will be migrated in follow-up PRs.
2023-07-17 17:56:07 +00:00
LongCatIsLooong
0d1cc33b65
_RenderScaledInlineWidget constrains child size (#130648)
Fixes https://github.com/flutter/flutter/issues/130588
2023-07-17 17:46:03 +00:00
LongCatIsLooong
bf4d659726
Allow OverlayPortal to be added/removed from the tree in a layout callback (#130670)
Fixes https://github.com/flutter/flutter/issues/130668
2023-07-17 17:46:00 +00:00
Michael Goderbauer
e06650bdbe
Guard access to dart:developer with !kReleaseMode (#130627) 2023-07-17 17:40:07 +00:00
Jason Simmons
7937b1d51f
Skip the iteration in Layer._fireCompositionCallbacks if the callbacks map is empty (#130438)
This was showing up as a hot spot in some benchmarks and profiles. This
function is called frequently during frame builds and often has an empty
map. There may be significant overhead from obtaining the values
iterator and cloning it into a list.

See https://github.com/flutter/flutter/issues/130339
2023-07-17 10:34:35 -07:00
Michael Goderbauer
6f09064e78
Stand-alone widget tree with multiple render trees to enable multi-view rendering (#125003)
This change enables Flutter to generate multiple Scenes to be rendered into separate FlutterViews from a single widget tree. Each Scene is described by a separate render tree, which are all associated with the single widget tree.

This PR implements the framework-side mechanisms to describe the content to be rendered into multiple views. Separate engine-side changes are necessary to provide these views to the framework and to draw the framework-generated Scene into them.

## Summary of changes

The details of this change are described in [flutter.dev/go/multiple-views](https://flutter.dev/go/multiple-views). Below is a high-level summary organized by layers.

### Rendering layer changes

* The `RendererBinding` no longer owns a single `renderView`. In fact, it doesn't OWN any `RenderView`s at all anymore. Instead, it offers an API (`addRenderView`/`removeRenderView`) to add and remove `RenderView`s that then will be MANAGED by the binding. The `RenderView` itself is now owned by a higher-level abstraction (e.g. the `RawView` Element of the widgets layer, see below), who is also in charge of adding it to the binding. When added, the binding will interact with the `RenderView` to produce a frame (e.g. by calling `compositeFrame` on it) and to perform hit tests for incoming pointer events. Multiple `RenderView`s can be added to the binding (typically one per `FlutterView`) to produce multiple Scenes.
* Instead of owning a single `pipelineOwner`, the `RendererBinding` now owns the root of the `PipelineOwner` tree (exposed as `rootPipelineOwner` on the binding). Each `PipelineOwner` in that tree (except for the root) typically manages its own render tree typically rooted in one of the `RenderView`s mentioned in the previous bullet. During frame production, the binding will instruct each `PipelineOwner` of that tree to flush layout, paint, semantics etc. A higher-level abstraction (e.g. the widgets layer, see below) is in charge of adding `PipelineOwner`s to this tree.
* Backwards compatibility: The old `renderView` and `pipelineOwner` properties of the `RendererBinding` are retained, but marked as deprecated. Care has been taken to keep their original behavior for the deprecation period, i.e. if you just call `runApp`, the render tree bootstrapped by this call is rooted in the deprecated `RendererBinding.renderView` and managed by the deprecated `RendererBinding.pipelineOwner`.

### Widgets layer changes

* The `WidgetsBinding` no longer attaches the widget tree to an existing render tree. Instead, it bootstraps a stand-alone widget tree that is not backed by a render tree. For this, `RenderObjectToWidgetAdapter` has been replaced by `RootWidget`.
* Multiple render trees can be bootstrapped and attached to the widget tree with the help of the `View` widget, which internally is backed by a `RawView` widget. Configured with a `FlutterView` to render into, the `RawView` creates a new `PipelineOwner` and a new `RenderView` for the new render tree. It adds the new `RenderView` to the `RendererBinding` and its `PipelineOwner` to the pipeline owner tree.
* The `View` widget can only appear in certain well-defined locations in the widget tree since it bootstraps a new render tree and does not insert a `RenderObject` into an ancestor. However, almost all Elements expect that their children insert `RenderObject`s, otherwise they will not function properly. To produce a good error message when the `View` widget is used in an illegal location, the `debugMustInsertRenderObjectIntoSlot` method has been added to Element, where a child can ask whether a given slot must insert a RenderObject into its ancestor or not. In practice, the `View` widget can be used as a child of the `RootWidget`, inside the `view` slot of the `ViewAnchor` (see below) and inside a `ViewCollection` (see below). In those locations, the `View` widget may be wrapped in other non-RenderObjectWidgets (e.g. InheritedWidgets).
* The new `ViewAnchor` can be used to create a side-view inside a parent `View`. The `child` of the `ViewAnchor` widget renders into the parent `View` as usual, but the `view` slot can take on another `View` widget, which has access to all inherited widgets above the `ViewAnchor`. Metaphorically speaking, the view is anchored to the location of the `ViewAnchor` in the widget tree.
* The new `ViewCollection` widget allows for multiple sibling views as it takes a list of `View`s as children. It can be used in all the places that accept a `View` widget.

## Google3

As of July 5, 2023 this change passed a TAP global presubmit (TGP) in google3: tap/OCL:544707016:BASE:545809771:1688597935864:e43dd651

## Note to reviewers

This change is big (sorry). I suggest focusing the initial review on the changes inside of `packages/flutter` first. The majority of the changes describe above are implemented in (listed in suggested review order):

* `rendering/binding.dart`
* `widgets/binding.dart`
* `widgets/view.dart`
* `widgets/framework.dart`

All other changes included in the PR are basically the fallout of what's implemented in those files. Also note that a lot of the lines added in this PR are documentation and tests.

I am also very happy to walk reviewers through the code in person or via video call, if that is helpful.

I appreciate any feedback.

## Feedback to address before submitting ("TODO")
2023-07-17 16:14:08 +00:00
Taha Tesser
a6187d9a92
Fix DatePicker uses incorrect overlay color from DatePickerTheme and add missing tests (#130584)
fixes [YearPickerState in calendar_date_picker is using dayOverlayColor instead of yearOverlayColor](https://github.com/flutter/flutter/issues/130051)

### Description

- Fix year selection uses incorrect overlay color from `DatePickerTheme`
- Update defaults tests to check for overlay color for different modes
- Add tests to check overlay color is resolved.

### Code sample

<details> 
<summary>expand to view the code sample</summary> 

```dart
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        datePickerTheme: const DatePickerThemeData(
          yearOverlayColor: MaterialStatePropertyAll<Color>(Colors.green),
          dayOverlayColor: MaterialStatePropertyAll<Color>(Colors.amber),
        ),
        useMaterial3: true,
      ),
      home: Directionality(
        textDirection: TextDirection.ltr,
        child: Material(
          child: Center(
            child: DatePickerDialog(
              initialDate: DateTime(2023, DateTime.january, 25),
              firstDate: DateTime(2022),
              lastDate: DateTime(2024, DateTime.december, 31),
              currentDate: DateTime(2023, DateTime.january, 24),
            ),
          ),
        ),
      ),
    );
  }
}

``` 
	
</details>

```dart
          yearOverlayColor: MaterialStatePropertyAll<Color>(Colors.green),
          dayOverlayColor: MaterialStatePropertyAll<Color>(Colors.red),
```

### Before
![Screenshot 2023-07-14 at 18 39 51](https://github.com/flutter/flutter/assets/48603081/52ec5096-bad6-4753-9e9a-15b6d5ce767e)

### After
![Screenshot 2023-07-14 at 18 38 32](https://github.com/flutter/flutter/assets/48603081/a51aeca8-a5c2-42b4-8c05-b55f9955e860)
2023-07-17 08:08:51 +00:00
Ian Hickson
5a866a031f
Clarify the whole "CustomPainters default to Size.zero" thing. (#130624)
Fixes https://github.com/flutter/flutter/issues/52707
2023-07-17 00:36:30 +00:00
Ian Hickson
a47c0803cf
Consistency in dependOnInheritedWidgetOfExactType guidance (#130632)
Fixes https://github.com/flutter/flutter/issues/47067
2023-07-14 23:37:10 +00:00
Ian Hickson
fa5869a462
Clarify docs on WidgetsBindingObserver (#130621)
Fixes https://github.com/flutter/flutter/issues/56102
2023-07-14 23:01:50 +00:00
Michael Goderbauer
5654bfe89a
Remove duplicated dart:ui imports (#130606)
Small clean up. A file probably doesn't need multiple way to refer to dart:ui concepts.
2023-07-14 22:47:12 +00:00
LongCatIsLooong
f2574ba1de
Use the new rounding hack migration flag in TextPainter (#130548) 2023-07-14 21:12:24 +00:00
Michael Goderbauer
d5c724eb07
Remove unused imports (#130603) 2023-07-14 13:36:02 -07:00
lsaudon
c3cd01661c
Tap on button behind snack bar defined by margin (#127959)
If the margin is used, set the `HitTestBehavior` to `deferToChild`. 

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

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
2023-07-14 06:58:00 +00:00
Ian Hickson
46125d07db
Mention saveLayer in the CustomPainter docs. (#130520)
Fixes https://github.com/flutter/flutter/issues/11002
2023-07-14 01:43:47 +00:00
Polina Cherkasova
3c2cd015cc
Inspector should not hold callback from garbage collection. (#130436) 2023-07-13 14:54:28 -07:00
Mouad Debbar
87d5214da6
[web] Migrate web-only initialization APIs (#129856)
- `ui_web.warmupEngine`
- `ui_web.setPluginHandler`
- `ui_web.debugEmulateFlutterTesterEnvironment`
2023-07-13 20:12:10 +00:00
Hans Muller
157660afc1
Change the default forThemeData.useMaterial3 to true (#129724)
Changes the default for `ThemeData.useMaterial3` to true.

See https://github.com/flutter/flutter/issues/127064
2023-07-13 13:06:03 -07:00
chunhtai
315ebafea3
PlatformRouteInformationProvider does not push new entry if query par… (#130457)
…ameter is semanticsally the same

The URI compare does not taking into account that query parameter may or may not be encoded, or the parameters' order can be different. However, they are all semantically the same. 

This pr makes PlatformRouteInformationProvider to take those into account when deciding whether it should push/replace the browser history entry.
2023-07-13 18:41:56 +00:00
chunhtai
2e8af2c35e
Unifies text field focus management in desktops (#129652)
related https://github.com/flutter/flutter/issues/128709

engine PR: https://github.com/flutter/engine/pull/43279

The web engine requires a way to unfocus textfield, It comes to nature
to me that we should leverage didGain/didLose a11y focus action. I also
unifies the action handler of all desktop platforms

## 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-07-13 10:41:16 -07:00
LongCatIsLooong
2da353a59a
Exclude Tooltip's overlay child from SelectableRegion (#130181)
Fixes https://github.com/flutter/flutter/issues/129969 by making tooltip text unselectable (for now). 
Also fixes some other issues uncovered when I was writing the tests.

Currently `getTransformTo` only works on ancestors. I'll try to add a new method that computes the transform from 2 arbitrary render objects in the same render tree in a follow-up PR and make `Selectable` use that method instead.
2023-07-13 00:35:57 +00:00
Srujan Gaddam
ab39bff282
Refactor JSNumber.toDart and Object.toJS (#129436)
JSNumber.toDart will now be two functions: toDartDouble and toDartInt.

There was code that did an Object.toJS. This has been changed to
use Function.toJS as well to make it consistent with the code
in flutter/packages:
0ef393811d/packages/web_benchmarks/lib/src/recorder.dart (L1223)

This is to help land this CL:
https://dart-review.googlesource.com/c/sdk/+/309082

https://dart-review.googlesource.com/c/sdk/+/309081 is the CL that added
the new methods.

## 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].
- [x] All existing and new tests are passing.
2023-07-12 13:54:15 -07:00