#83531 contains complaints that this default disabled color can no longer be overridden by setting a color of the `decoration` property. This regression was introduced by #78058, which was itself made to fix an issue where the color of the decoration was always used even when disabled.
Currently, when the text field is disabled, its color is set to a default disabled color. This PR makes it so that if a decoration is set when the text field is disabled, its color is used instead of the default disabled color.
Fixes https://github.com/flutter/flutter/issues/83531
Switch away from the `Iterable.castFrom` static method to the `Iterable.cast` instance method which is more readable and more consistent with other iterable usages.
This PR just has a tiny doc change to correct the doc for `ColorScheme.surface`. Previously, Card background color defaults to `ColorScheme.surface` but we updated the default since we've introduced the new tone-based surface colors, like `surfaceContainer`, `surfaceContainerLow` and etc. The `surface` in ColorScheme should now replace deprecated `background` which is the default background color of Scaffold.
Related to the comment here: https://github.com/flutter/flutter/pull/149772#issuecomment-2157596540
The original approach in https://github.com/flutter/flutter/pull/149609 didn't work when the Flutter Gradle plugin was applied using the deprecated script apply - the kotlin portion couldn't resolve the custom exception defined in `flutter.groovy`:
```
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:238:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:263:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:288:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:313:23: Unresolved reference: DependencyValidationException
Warning: Flutter was unable to detect project Gradle, Java, AGP, and KGP versions. Skipping dependency version checking. Error was: org.gradle.internal.exceptions.LocationAwareException: Script '/Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts' line: 238
Script compilation errors:
Line 238: throw DependencyValidationException(errorMessage)
^ Unresolved reference: DependencyValidationException
Line 263: throw DependencyValidationException(errorMessage)
^ Unresolved reference: DependencyValidationException
Line 288: throw DependencyValidationException(errorMessage)
^ Unresolved reference: DependencyValidationException
Line 313: throw DependencyValidationException(errorMessage)
^ Unresolved reference: DependencyValidationException
```
This new approach of setting one of the [`extra` properties](https://docs.gradle.org/current/dsl/org.gradle.api.Project.html#N14FF7) works in both cases (tested with the `camera_android` example app, which uses the script apply, and a freshly created counter app).
It also removes some brittleness in that we don't have to unwrap the exception anymore, and aren't subject to breaking if Gradle decides one day to wrap our custom exception 1 layer deeper in additional exceptions.
Fixes https://github.com/flutter/flutter/issues/145158.
In an ideal world, the `--machine` flag would be strictly a global flag which sub-commands can choose to use (or perhaps just to report a `toolExit` that they don't have a `--machine` supported-mode if not. However currently, there is both a global flag, and command-specific flags.
This leads to the confusing scenario where:
```sh
flutter devices --machine
```
... still checks for a Flutter update, printing a banner and breaking the JSON output.
This PR "fixes" that by allowing `--machine` _anywhere_ in the command-line arguments to suppress the check.
/cc @johnmccutchan.
Relands https://github.com/flutter/flutter/pull/149739 which was reverted due to https://github.com/flutter/flutter/issues/149851
---
fixes [`SegmentedButton` doesn't clip properly when one of the segments has `ColorFiltered`](https://github.com/flutter/flutter/issues/144990)
### 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(
home: Scaffold(
body: Center(
child: SegmentedButton<int>(
segments: const <ButtonSegment<int>>[
ButtonSegment<int>(
value: 0,
label: ColorFiltered(
colorFilter:
ColorFilter.mode(Colors.amber, BlendMode.colorBurn),
child: Text('Option 1'),
),
),
ButtonSegment<int>(
value: 1,
label: Text('Option 2'),
),
],
onSelectionChanged: (Set<int> selected) {},
selected: const <int>{0},
),
),
),
);
}
}
```
</details>
### Before

### After

*Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.*
*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.*
*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
Adds `mouseCursor` property in `Radio` to `CupertinoRadio` and `Radio.adaptive`.
The `mouseCursor` property added is of type `MouseCursor` and not `WidgetStateProperty<MouseCursor>` to match `Radio`'s `mouseCursor`.
## Description
This PRs fixes `DropdownMenu` behaviors when disabled.
Before this PR the `DropdownMenu` value can be changed when `DropdownMenu.enabled` was false because the inner `IconButton` was not disabled so it can get focus (for instance using tab key).
After this PR, the inner `TextField` and the inner `IconButton` are disabled when `DropdownMenu.enabled` is false.
## Related Issue
Fixes https://github.com/flutter/flutter/issues/149598.
## Tests
Updates 1 test.
Adds 1 test.
The new service extension `getRootWidgetTree` can be used instead of the existing:
* `getRootWidgetSummaryTree` --> use`getRootWidgetTree` with parameters `isSummaryTree=true`
* `getRootWidgetSummaryTreeWithPreviews` --> use `getRootWidgetTree` with parameters `isSummaryTree=true` and `withPreviews=true`
This new service extension will enable Flutter DevTools to combine the widget summary tree with the widget details tree by calling `getRootWidgetTree` with `isSummary=false` and `withPreviews=true`.
Closes https://github.com/flutter/devtools/issues/7894
Currently, the error message displayed to regenerate the lockfiles gives a Unix-like command ./gradlew, which will be incorrect for Windows environments. This PR uses globals.platform.isWindows to give the appropriate command.
closes#136763
This sentence didn't make a lot of sense as written. It looks like
it was probably based on the doc of invokeMapMethod, and then
incompletely adapted. So, fix it.
Reverts: flutter/flutter#150015
Initiated by: vashworth
Reason for reverting: Still failing tree on goldens
Original PR Author: dkwingsmt
Reviewed By: {chunhtai}
This change reverts the following previous change:
Relands #149568, which was reverted in https://github.com/flutter/flutter/pull/149998 due to unverified golden tests post-commit. (Honestly I don't know what happened but I guess resubmitting should resolve it.)
No code is changed.
Dart2Wasm doesn't officially support `dart:ffi` (only a small sketchy
subset needed in flutter web engine). We have seen user reporting issues
where existing packages don't work with dart2wasm due to using
`dart.library.ffi` in `bool.fromEnvironment` or in conditional imports
and it doing the wrong thing. So we're going to make `dart.library.ffi`
`false` in the compiler.
We therefore update the code to detect whether it runs under wasm via a
new `dart.tool.dart2wasm` environment variable.
This is a preparation for the change in dart2wasm which will start
making `const bool.fromEnvironment('dart.library.ffi')` return `false`
instead of `true`.
Notifies the engine when `PointerSignalEvents` have been ignored by the framework, through the `ui.PointerData.respond` method.
This allows the web to "preventDefault" (or not) on `wheel` events.
## Issues
* Fixes (partially): https://github.com/flutter/flutter/issues/139263
## Tests
* Added tests to ensure `respond` is called at the right time, with the right value.
## Demo
* https://dit-multiview-scroll.web.app
<details>
<summary>
## Previous versions
</summary>
1. Modified `PointerScrollEvent`, not shippable.
2. Modified when events were handled, instead of the opposite.
</details>
This PR addresses an issue with TextPainter's caret position calculation for text containing full-width spaces. Currently, the caret position is not accurately calculated for strings with full-width spaces. To resolve this, the following changes have been made:
Corrected the logic for caret position calculation when full-width spaces are present in the text.
Added and updated test cases to ensure accurate caret position calculation.
These changes ensure that the caret position for text with full-width spaces is computed correctly.
This issue was introduced by the commit [a0a854a](a0a854a78b).
Related Issue: [#149099](https://github.com/flutter/flutter/issues/149099)
- When `--web-renderer` is omitted, keep the value `null` until it later materializes to either `canvaskit` or `skwasm`.
- No more hardcoded defaults anywhere. We use `WebRendererMode.defaultForJs/defaultForWasm` instead.
- When in `--wasm` mode, the JS fallback is now `canvaskit` instead of `auto`.
- Add test for defaulting to `skwasm` when `--wasm` is enabled.
Fixes https://github.com/flutter/flutter/issues/149826
This reverts commit 32081aab69f82f88283cf43ce4cc2f9544c7c16c.
Reason for revert: Appears to be failing tests in tree
```
01:48 +2991 ~18: /Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/cupertino/action_sheet_test.dart: Taps on a button can be slided to other buttons
âââ¡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK âââââââââââââââââââââââââââââââââââââââââââââââââââââ
The following SkiaException was thrown while running async test code:
Skia Gold received an unapproved image in post-submit
testing. Golden file images in flutter/flutter are triaged
in pre-submit during code review for the given PR.
Visit https://flutter-gold.skia.org/ to view and approve
the image(s), or revert the associated change. For more
information, visit the wiki:
https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package:flutter
Debug information for Gold --------------------------------
stdout: Given image with hash 601f421e3bb643f437cc12395de96152 for test
cupertino.cupertinoActionSheet.press-drag
Expectation for test: ce8ef79c146857d162663b1161fd6d5c (positive)
Expectation for test: 3bb57a8782f67836c6ad3ece7f00729a (positive)
Expectation for test: 3f8c592774caf3c760fbbd318a7dc5af (positive)
Expectation for test: 61863f38217aa3349c239eeb49b84930 (positive)
Expectation for test: 98af16e9b7eb3fb810b44c74bb18ffb9 (positive)
Untriaged or negative image:
https://flutter-gold.skia.org//detail?grouping=name%3Dcupertino.cupertinoActionSheet.press-drag%26source_type%3Dflutter&digest=601f421e3bb643f437cc12395de96152
stderr: Test: cupertino.cupertinoActionSheet.press-drag FAIL
result-state.json: No result file found.
```
This PR matches the various colors of `CupertinoActionSheet` more closely with the native one.
The following colors are changed.
* Sheet background color
* Pressed button color
* Cancel button color
* Pressed cancel button color
* Divider color
* Content text color
The resulting colors match with native one with deviation of at most 1 (in terms of 0~255 RGB).
The following are comparison (left to right: Native, Flutter after PR, Flutter current)
<img width="1295" alt="image" src="https://github.com/flutter/flutter/assets/1596656/3703a4a8-a856-42b1-9395-a6e14b1881ca">
<img width="1268" alt="image" src="https://github.com/flutter/flutter/assets/1596656/1eb9964e-41f1-414a-99ae-0a2e7da8d3fd">
_Note: The divider thickness is adjusted to `1/dpr` instead of 0.3 in both Flutter version to make them look more native, as will be proposed in https://github.com/flutter/flutter/pull/149636._
### Derivation
All the colors are derived through color picker and calculation. The algorithm is as followed:
* Assume all colors are translucent grey colors, i.e. having the same value `x` for R, G, and B, with an alpha `a`.
* Given the barrier color is `x_B1=0` when the background is black, and `x_B2=204` when the background is white.
* Pick the target color `x_t1` when the background is black, and `x_t2` when the background is white
* Solve the following equations for `x` and `a`
```
a * x + (1-a) * x_B1 = x_t1
a * x + (1-a) * x_B2 = x_t2
a = 1 - (x_t1 - x_t2) / (x_B1 - x_B2)
x = (x_t1 - (1-a) * x_B1) / a
```
These equations use a linear model for color composition, which might not be exact, but is close enough for an accuracy of (1/255).
The full table is as follows:
<img width="1091" alt="image" src="https://github.com/flutter/flutter/assets/1596656/0fb76291-c3cc-4bb5-aefa-03ac6ac9bf1f">
* The first two columns are colors picked from XCode.
* The 3~4 columns are the colors picked from the current Flutter. Notice the deviation, which is sometimes drastic.
* The 5~6 columns are the colors picked from Flutter after this PR. The deviation is at most 1.
* The last few columns are calculation.
* There are two rows whose calculation is based on adjusted numbers, since the original results are not accurate enough, possibly due to the linear composition.
During the calculation, I assumed these colors vary between light and dark modes, but it turns out that both modes use the same set of colors.
### Screenshots
This reverts commit 9d1de7b674866e3c8726aa5c949200eb3eb886ea.
Reverts due to log spam and crashing of the dependency version checker (which doesn't block the build but still isn't the desired outcome).
Work towards https://github.com/flutter/devtools/issues/7894
The Flutter DevTools team is working on a new Widget Inspector. As part of this work, we need to make adjusts to the widget inspector service API.
This PR simply re-factors the `widget_inspector_test` in preparation for this work, to make it easier for us to modify the tests / add new tests.
Although this PR is large (`widget_inspector_test` is over 5000 lines!!), it does not change any of the current test logic.
Instead it:
- Moves test cases that were prefixed with "WidgetInspectorService" into the pre-existing group named "WidgetInspectorService"
- Moves tests cases in that group which were skipped with `!WidgetInspectorService.instance.isWidgetCreationTracked() // [intended] Test requires --track-widget-creation flag` into a group called "Requires flag --track-widget-creation"
- Adds two helper functions, `pumpWidgetTreeWithABC` and `findElementABC` and uses them in all test cases that were duplicating the same widget set-up.