Reverts: flutter/flutter#147856
Initiated by: loic-sharma
Reason for reverting: tree is closed with errors like:
```
test/integration.shard/break_on_framework_exceptions_test.dart: breaks when rebuilding dirty elements throws [E]
Expected: <45>
Actual: <2756>
package:matcher expect
test\integration.shard\break_on_framework_exceptions_test.dart 56:5 main.expectException
===== asynchronous gap ===
Original PR Author: LongCatIsLooong
Reviewed By: {goderbauer}
This change reverts the following previous change:
Fixes https://github.com/flutter/flutter/issues/146379: introduces `Element.buildScope` which `BuildOwner.buildScope` uses to identify subtrees that need skipping (those with different `BuildScope`s). If `Element.update` calls `updateChild` then dirty children will still be rebuilt regardless of their build scopes.
This also introduces `LayoutBuilder.applyDoubleRebuildFix` migration flag which should only live for a week or less.
Caveats:
`LayoutBuilder`'s render object calls `markNeedsLayout` if a descendant Element is dirty. Since `markNeedsLayout` also implies `markNeedsPaint`, the render object is going to be very repaint/relayout-happy.
Tests:
Presubmits with the migration flag set to true: https://github.com/flutter/flutter/pull/147856/checks?check_run_id=24629865893
These tests essentially count the number of values in the engine enums. https://github.com/flutter/engine/pull/53094 is adding a new value, which causes these tests to fail. Temporarily disabling these tests so that the engine change can proceed.
Fixes https://github.com/flutter/flutter/issues/146379: introduces `Element.buildScope` which `BuildOwner.buildScope` uses to identify subtrees that need skipping (those with different `BuildScope`s). If `Element.update` calls `updateChild` then dirty children will still be rebuilt regardless of their build scopes.
This also introduces `LayoutBuilder.applyDoubleRebuildFix` migration flag which should only live for a week or less.
Caveats:
`LayoutBuilder`'s render object calls `markNeedsLayout` if a descendant Element is dirty. Since `markNeedsLayout` also implies `markNeedsPaint`, the render object is going to be very repaint/relayout-happy.
Tests:
Presubmits with the migration flag set to true: https://github.com/flutter/flutter/pull/147856/checks?check_run_id=24629865893
Since we are using The `CupertinoScrollBar` for both macOS and iOS, it's a good idea to update the description of the `adaptive` function to indicate it will be used for macOS and iOS
*Update progress_indicator.dart to indicate the adaptive option is for both macOS and iOS.*

According to previous discussion at https://github.com/flutter/flutter/pull/145389#discussion_r1561564845, this change makes `_ModalScopeStatus` an `InheritedModel` rather than an `InheritedWidget`, and provides the following methods.
- `isCurrentOf`
- `canPopOf`
- `settingsOf`
For example, `ModalRoute.of(context)!.settings` could become `ModalRoute.settingsOf(context)` as a performance optimization.
Fixes: https://github.com/flutter/flutter/issues/58765
The rationale for the choice of the sentinel value: https://github.com/flutter/engine/pull/52940
The exact value of `kTextHeightNone` should be kept as an implementation detail. It's unfortunate that the current value `0` is dangerously close to `TextStyle.height`'s valid domain. If we ever allow `TextStyle.height == 0` (which totally makes sense) then it shouldn't be difficult to change the const.
The PR changes the default value of hitTestBehavior in snack bars to `HitTestBehavior.deferToChild` when snackBarTheme.insetPadding is not null, so that widgets behind snack bars affected by the value set to insetPadding, remain interactive even while a snack bar is visible. This PR can be considered as an extension to what have been done in PR #127959 which fixes the same problem but for individual snack bars with margin not being null. This PR works on the theme level.
*List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.*
#148566
Reverts: flutter/flutter#148470
Initiated by: eyebrowsoffire
Reason for reverting: Unit test failures closing the tree.
Original PR Author: hello-coder-xu
Reviewed By: {QuncCccccc, Piinks}
This change reverts the following previous change:
* sliverGridDelegate mainAxisExtent add assert,Avoid incorrect use *
Fixes https://github.com/flutter/flutter/issues/138871
It's now possible to override the default selection overlay with CupertinoDatePicker.selectionOverlayBuilder and CupertinoTimerPicker.selectionOverlayBuilder.
Dart2wasm only needs a platform file, which contains the compiled
`dart:*` libraries. There's no need to specify a seperate `--dart-sdk`
option (anymore).
(See also https://dart-review.googlesource.com/c/sdk/+/366821)
## Description
This PRs fixes a Web issue on Linux related to numpad keys.
In https://github.com/flutter/flutter/pull/145464, I introduced numpad shortcuts for Linux. These shortcuts work well on a desktop Linux application but they broke the Linux+Web numpad logic.
When I added these shortcuts, I expected them to not be active on Web (because I knew that on Web, those shortcuts are handled by the browser). But there is a trick: text editing shortcuts are still defined on Web but they are disabled at the editable text level so one can use them in components that are not `EditableText` (see https://github.com/flutter/flutter/pull/103377).
In this PR, I used the same approach than for other text editing shortcuts: when on web associate those shortcuts to the `DoNothingAndStopPropagationTextIntent` intent.
## Related Issue
Fixes https://github.com/flutter/flutter/issues/148447.
## Tests
Updates 2 tests.
Adds 2 tests.
- Fixes a child not removed from `_keepAliveBucket` when widget is no longer kept alive offscreen. Bug was triggering assert in performLayout.
- Adds test to cover the case from bug report
Fixes#138977
It looks like removing `kIsWeb` from the `FocusManager._appLifecycleListener` platform check is causing [memory leaks](https://github.com/flutter/flutter/issues/148985) and test failures.
This pull request fixes#148475 and prevents the test failures shown in #148978.
This is part 16 of a broken down version of the #140101 refactor.
This only makes one dependency explicit. Further PRs will do the same for other dependencies, until these APIs have no hidden dependencies.
This PR makes no effort to keep the order of parameters reasonable. There is an existing TODO to do a refactor sweep later that does nothing but reorder arguments/parameters/fields to be consistent.
Both iOS and Android run into issues when the FocusManager starts responding to app lifecycle changes.
Fortunately, this feature is primarily meant for desktop platforms, so the problem can be resolved with a platform check.
fixes https://github.com/flutter/flutter/issues/148475
This PR modifies the `flutter create --empty` command to not delete the `test/` folder when run on an existing app project.
Before:
```bash
flutter create my_app --empty
mkdir my_app/test
if test -d my_app/test; then echo "test exists"; else echo "test does not exist"; fi # test exists
flutter create my_app --empty
if test -d my_app/test; then echo "test exists"; else echo "test does not exist"; fi # test does not exist
```
After:
```bash
flutter create my_app --empty
mkdir my_app/test
if test -d my_app/test; then echo "test exists"; else echo "test does not exist"; fi # test exists
flutter create my_app --empty
if test -d my_app/test; then echo "test exists"; else echo "test does not exist"; fi # test exists
```
Fixes https://github.com/flutter/flutter/issues/134928
This PR adds support invoking `link.dart` hooks.
Link hooks can add new assets. Link hooks can transform assets sent to link hook from build hooks.
This PR does not yet add support for getting tree-shake information in the link hooks. This is pending on defining the `resources.json` format (https://github.com/dart-lang/sdk/issues/55494).
Issue:
* https://github.com/flutter/flutter/issues/146263
## Implementation considerations
The build hooks could be run before Dart compilation and the link hooks after Dart compilation. (This is how it's done in Dart standalone.) However, due to the way the `Target`s are set up, this would require two targets and serializing and deserializing the `BuildResult` in between these. This would lead to more code but no benefits. Currently there is nothing that mandates running build hooks before Dart compilation.
## Testing
* The unit tests verify that the native_assets_builder `link` and `linkDryRun` would be invoked with help of the existing fake.
* The native assets integration test now also invokes an FFI call of a package that adds the asset during the link hook instead of the build hook.
* In order to keep coverage of the `flutter create --template=package_ffi`, `flutter create` is still run and the extra dependency is added and an extra ffi call is added. (Open to alternative suggestions.)
This PR adds a new flag `default-flavor` in the `flutter` section of `pubspec.yaml`. It allows developers of multi-flavor android apps to specify a default flavor to be used for `flutter run`, `flutter build` etc.
Using `flutter run` on flavored apps already works without specifying `--flavor` already works on iOS (it defaults to the `runner` schema), so I (and others in #22856) figured this would be nice to have.
fixes#22856
Tests in Material toggleables (`Radio`, `Switch`, `Checkbox`) which require hovering using a mouse pointer do not include `addTearDown(gesture.removePointer)` to remove the mouse pointer once the test concludes.
Also, hovering tests in Material `Checkbox` currently have no functionality (i.e what is painted before hovering = what is painted while hovering). For example:
357bd65749/packages/flutter/test/material/checkbox_test.dart (L880-L896)
This PR adds `addTearDown(gesture.removePointer)` to `Radio`, `Switch`, and `Checkbox` tests, and functionality for `Checkbox` hover tests.
Fixes#148809.
Contributes to https://github.com/flutter/flutter/issues/145599
Repro:
`flutter test test/cupertino/tab_scaffold_test.dart --dart-define LEAK_TRACKING=true --plain-name "Adding new tabs does not crash the app"`
What is going on:
1. ImageCache.putIfAbsent, in case the image already existed in the cache, invokes ImageCache._trackLiveImage, that creates _LiveImage and passes the image's completer as parameter `completer`
3. _LiveImage constructor invokes super constructor (of _CachedImageBase) that initializes the member `handle`
4. `handle` is disposed [using scheduler](c698e694c8/packages/flutter/lib/src/painting/image_cache.dart (L633)), and disposal does not happen in time of test completion.
Adding delay to the test increases number of not disposed objects from 30 to 120.
Should we force schedule at the end of the widget tests somehow to make scheduler switched to right state?
Creation call stack:
```
#9______new_ImageStreamCompleterHandle.__(package:flutter/src/painting/image_stream.dart:465:41)
#10_____ImageStreamCompleter.keepAlive_(package:flutter/src/painting/image_stream.dart:655:39)
#11_____new__CachedImageBase_(package:flutter/src/painting/image_cache.dart:609:27)
#12_____new__LiveImage_(package:flutter/src/painting/image_cache.dart:647:9)
#13_____ImageCache._trackLiveImage.<anonymous_closure>_(package:flutter/src/painting/image_cache.dart:302:14)
#14______LinkedHashMapMixin.putIfAbsent_(dart:collection-patch/compact_hash.dart:543:23)
#15_____ImageCache._trackLiveImage_(package:flutter/src/painting/image_cache.dart:296:17)
#16_____ImageCache.putIfAbsent_(package:flutter/src/painting/image_cache.dart:378:7)
#17_____ImageProvider.resolveStreamForKey_(package:flutter/src/painting/image_provider.dart:517:81)
#18_____ScrollAwareImageProvider.resolveStreamForKey_(package:flutter/src/widgets/scroll_aware_image_provider.dart:104:19)
#19_____ImageProvider.resolve.<anonymous_closure>_(package:flutter/src/painting/image_provider.dart:366:9)
#20_____ImageProvider._createErrorHandlerAndKey.<anonymous_closure>_(package:flutter/src/painting/image_provider.dart:479:24)
#21_____SynchronousFuture.then_(package:flutter/src/foundation/synchronous_future.dart:43:39)
#22_____ImageProvider._createErrorHandlerAndKey_(package:flutter/src/painting/image_provider.dart:476:9)
#23_____ImageProvider.resolve_(package:flutter/src/painting/image_provider.dart:363:5)
#24______ImageState._resolveImage_(package:flutter/src/widgets/image.dart:1111:16)
#25______ImageState.didChangeDependencies_(package:flutter/src/widgets/image.dart:1061:5)
#26_____StatefulElement._firstBuild_(package:flutter/src/widgets/framework.dart:5630:11)
#27_____ComponentElement.mount_(package:flutter/src/widgets/framework.dart:5457:5)
#28_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4334:16)
#29_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3843:18)
#30_____SingleChildRenderObjectElement.mount_(package:flutter/src/widgets/framework.dart:6763:14)
```
Newer Gradle/AGP versions include the following warnings:
```
w: file:///Users/goderbauer/dev/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:107:40: Variable 'agpVersion' initializer is redundant
w: file:///Users/goderbauer/dev/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:108:40: Variable 'kgpVersion' initializer is redundant
w: file:///Users/goderbauer/dev/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:143:28: Parameter 'project' is never used
w: file:///Users/goderbauer/dev/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:152:40: Variable 'agpVersion' initializer is redundant
w: file:///Users/goderbauer/dev/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:167:55: 'Version' is deprecated. Deprecated in Java
w: file:///Users/goderbauer/dev/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:195:56: Unnecessary non-null assertion (!!) on a non-null receiver of type Any
w: file:///Users/goderbauer/dev/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:344:28: The corresponding parameter in the supertype 'Comparable' is named 'other'. This may cause problems when calling this function with named arguments.
```
These also get printed out to the CLI, so they are somewhat annoying.
Fixes all of the warnings, except for `'Version' is deprecated. Deprecated in Java`, which gets suppressed (we are intentionally using the deprecated `Version`, to help support older versions of AGP that use that deprecated class).