https://github.com/flutter/flutter/pull/151599 was reverted because it was a breaking change to g3
Will reland 151599 in 5 steps
1. Make changes with an additional parameter ( bool internalAddSemanticForOnTap = false)
2. Send regular CLs in google3 to pass internalAddSemanticForOnTap: true, and update the tests / text goldens accordingly.
3. Send a PR to flip the default value to true.
4. Send CLs internally to remove internalAddSemanticForOnTap: true.
5. Send another PR to remove the now-redundant internalAddSemanticForOnTap flag.
(<----This PR is step 1)
## Description
This adds `find.backButton()` in the Common Finders to allow finding different types of standard UI elements. It works by attaching a key made from an enum value in a new enum called `StandardComponentType` to all of the standard widgets that perform the associated function.
I also substituted the finder in several places where it is useful in tests.
This allows writing tests that want to find the "back" button without having to know exactly which icon the back button uses under what circumstances. To do it correctly is actually quite complicated, since there are several adaptations that occur (based on platform, and whether it is web or not).
## Tests
- Added tests.
This PR is to make preparations to make `CardTheme` conform to Flutter's conventions for component themes:
* Added a `CardThemeData` class which defines overrides for the defaults for `Card` properties.
* Added 2 `CardTheme` constructor parameters: `CardThemeData? data` and `Widget? child`. This is now the preferred way to configure a `CardTheme`:
```dart
CardTheme(
data: CardThemeData(color: xxx, elevation: xxx, ...),
child: Card(...)
)
```
These two properties are made nullable to not break existing apps which has customized `ThemeData.cardTheme`.
* Changed the type of theme defaults from `CardTheme` to `CardThemeData`.
TODO:
* Fix internal failures that may have breakages.
* Change the type of `ThemeData.cardTheme` from `CardTheme` to `CardThemeData`. This may cause breaking changes, a migration guide will be created.
Addresses the "theme normalization" sub project within https://github.com/flutter/flutter/issues/91772
On Xcode 16 beta 3 stderr is:
```
** BUILD FAILED **
```
stdout is:
```
Writing result bundle at path:
/var/folders/fm/wjzsj_z95ydgn4khxqgbtqx000mfq2/T/flutter_tools.PeJZlH/flutter_ios_build_temp_dirqmiKld/temporary_xcresult_bundle
error: lib/main.dart:13:11: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
int x = 'String';
^
Target kernel_snapshot_program failed: Exception
Failed to package /Users/m/Projects/test_create.
note: Disabling previews because SWIFT_VERSION is set and SWIFT_OPTIMIZATION_LEVEL=-O, expected -Onone (in target 'Runner' from project 'Runner')
note: Run script build phase 'Thin Binary' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')
note: Run script build phase 'Run Script' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')
```
The tool output of `flutter build ios` shows both:
```
Building com.example.testCreate for device (ios-release)...
Automatically signing iOS for device deployment using specified development team
in Xcode project: S8QB4VV633
Running Xcode build...
Xcode build done. 10.1s
Failed to build iOS app
Error output from Xcode build:
â³
** BUILD FAILED **
Xcode's output:
â³
Writing result bundle at path:
/var/folders/fm/wjzsj_z95ydgn4khxqgbtqx000mfq2/T/flutter_tools.Dgnlxc/flutt
er_ios_build_temp_dirpKTDdk/temporary_xcresult_bundle
error: lib/main.dart:13:11: Error: A value of type 'String' can't be
assigned to a variable of type 'int'.
int x = 'String';
^
Target kernel_snapshot_program failed: Exception
Failed to package /Users/magder/Projects/test_create.
note: Disabling previews because SWIFT_VERSION is set and
SWIFT_OPTIMIZATION_LEVEL=-O, expected -Onone (in target 'Runner' from
project 'Runner')
note: Run script build phase 'Run Script' will be run during every build
because the option to run the script phase "Based on dependency analysis" is
unchecked. (in target 'Runner' from project 'Runner')
note: Run script build phase 'Thin Binary' will be run during every build
because the option to run the script phase "Based on dependency analysis" is
unchecked. (in target 'Runner' from project 'Runner')
Encountered error while building for device.
```
The point of this test is that you can see the error `int x = 'String';` error in the tool output. https://github.com/flutter/flutter/issues/72608#issuecomment-797473109
I think just updating the test to check stderr or stdout is sufficient without touching the tool behavior.
Fixes https://github.com/flutter/flutter/issues/151553
If Swift Package Manager is enabled, the tool generates a Swift package at `<ios/macos>/Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage/`. This Swift package is how the tool adds plugins to the Flutter project.
SwiftPM is strictly enforces platform versions: you cannot depend on a Swift package if its supported version is higher than your own.
On iOS, we use the project's minimum deployment version for the generated Swift package. If a plugin has a higher requirement, you'll need to update your project's minimum deployment version. The generated Swift package is automatically updated the next time you run the tool.
This updates macOS to do the same thing.
Fixes https://github.com/flutter/flutter/issues/146204
This reverts commit 7cdc23b3e1bae2bc7bc2d1f34773eaa3629d4fcc.
The failure in the `native_assets_test` integration test on Windows was caused by the DevTools process not being shutdown by the `ColdRunner` when running the profile mode portion of the test. This resulted in the test being unable to clean up the project created by the test as DevTools was still holding onto a handle within the directory. This PR adds back the mistakenly removed DevTools shutdown logic in the `ColdRunner`.
Resolves#151446
`DragGestureRecognizer` defines several private abstract methods that are implemented by its subclasses.
In the **super_editor** package, we'd like to extend `PanGestureRecognizer` to make it more aggressive, so it can win the gesture arena when placed inside a `CustomScrollview`. However, since we can't override private methods, tweaking this single function would involve copying the entire `DragGestureRecognizer` interface and its `PanGestureRecognizer` implementation.
<br>
Methods that were updated in this PR:
| Method | Rationale |
|---|---|
| `_hasSufficientGlobalDistanceToAccept` | This is the most important method for us. Overriding this method allows tweaking the PanGestureRecognizer to be more aggressive. |
| `_considerFling` | In **super_editor** we use the PanGestureRecognizer, but we want the fling gesture to behave as if it was a VerticalDragRecognizer. We'll use the fling gesture just to scroll vertically. |
| `_finalPosition` | I added a getter to be able to access it inside `_considerFling`. |
| `_globalDistanceMoved` | I added a getter to be able to access it inside `_hasSufficientGlobalDistanceToAccept`. |
Feat: Drag handle size can now be changed to any given size.
So, In previous behaviour drag handle size was not able to extends beyond 48x48. But some user might want to change it.
In current behaviour, drag handle size is default to same 48x48 but if drag handle size grows beyond that, we don't restrict it.
Fixes#149170
Closes https://github.com/flutter/flutter/issues/152325.
This PR is large due to generate `flutter create --platforms android`. A quick summary:
- Moves the integration test from `packages/flutter_driver/test` to `dev/integration_tests`
- Created a sample Flutter app that draws a blue rectangle
- Forked a subset of `package:flutter_goldens` that will work on the standalone Dart VM
- Forked a subset of `goldens.dart` (from `flutter_test`) to `src/native/goldens.dart` (i.e. `matchesGoldenFile`)
This ... works locally, but as usual I have no idea if it will work on Skia Gold so let's roll some dice.
## Description
This adds a call to the `PlatformDispatcher` whenever the focus changes, so that the engine can decide what to do about view focus. This lets widgets use autofocus, and when they are focused their view will also receive focus.
## Related Issues
- Fixes https://github.com/flutter/flutter/issues/151251
## Tests
- Added a test and some methods to the `TestPlatformDispatcher` to allow introspection of the values sent.
https://github.com/flutter/flutter/issues/150800. The 2nd batch of `widgets` library `@docImport`s.
After this patch, in the `widgets` library:
```
Can not fully resolve ../../flutter/packages/flutter/lib/src/widgets/scroll_view.dart: (TargetPlatformVariant.mobile)
Can not fully resolve ../../flutter/packages/flutter/lib/src/widgets/_platform_selectable_region_context_menu_web.dart: (ui_web.platformViewRegistry.registerViewFactory)
Can not fully resolve ../../flutter/packages/flutter/lib/src/widgets/primary_scroll_controller.dart: (TargetPlatformVariant.mobile)
Can not fully resolve ../../flutter/packages/flutter/lib/src/widgets/selectable_region.dart: (material, WidgetTester.dragFrom)
Can not fully resolve ../../flutter/packages/flutter/lib/src/widgets/basic.dart: (ui.Gradient.linear)
Can not fully resolve ../../flutter/packages/flutter/lib/src/widgets/framework.dart: (Finder)
Can not fully resolve ../../flutter/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart: (WidgetTester.pumpAndSettle)
Can not fully resolve ../../flutter/packages/flutter/lib/src/widgets/binding.dart: (WidgetTester.restartAndRestore, WidgetTester.pumpWidget, TestWidgetsFlutterBinding, testWidgets, TestWidgetsFlutterBinding.ensureInitialized)
Can not fully resolve ../../flutter/packages/flutter/lib/src/widgets/localizations.dart: (GlobalWidgetsLocalizations)
Can not fully resolve ../../flutter/packages/flutter/lib/src/widgets/scroll_controller.dart: (WidgetTester.pumpAndSettle)
Can not fully resolve ../../flutter/packages/flutter/lib/src/widgets/scrollbar.dart: (TargetPlatformVariant.desktop)
21 out-of-scope references in 11 files, 16 unique symbols were left unresolved.
```
Turns out just supporting the right value for `kDebugMode` was a lot simpler than I thought. Debug builds used to never go through the build system code path when using `flutter run`, but now that we have wasm this can occur with the run command.
This should address https://github.com/flutter/flutter/issues/148850
## Description
This PR attemps to clarify the `InputDecoration.collapsed` documentation by explaining that it is not meant to be use with helper, label, counter, icons, prefixes and suffixes.
It also adds some parameters that make sense for a collapsed decoration (`hintMaxLines`, `hintFadeDuration`, `constraints`).
Removing parameters that should not have been added (`floatingLabelBehavior` and `floatingLabelAlignment`) will be part of another PR as it will require deprecations.
## Related Issue
Fixes https://github.com/flutter/flutter/issues/61331
## Tests
Adds 3 tests.
The current example:
> for example, when unlimited width is available and
/// you would like a child that would otherwise attempt to expand infinitely to
/// instead size itself to a more reasonable width.
doesn't seem to be the most useful example because most leaf widgets will just size themselves to their intrinsic size if the incoming constraints are not tight, so when
I was reading the doc I wasn't able to come up with any concrete widget combination that would require the use of `IntrinsicHeight`.
Updates the expected steps in the async function defined within `stepping_project.dart`.
The Dart web team is updating the async semantics of DDC to bring them in line with the other backends. Currently, the DDC async semantics don't adhere to the Dart spec and this can lead to inconsistent and surprising results.
However, the step-over operation doesn't work well yet with the new DDC async semantics. In the long run we intend to improve this but until then the debug stepper will have sporadic results that we can't model well with this test. When we are able to fix the stepper functionality, we will return this test to cover more of the async function being stepped over.
Upcoming changes to DDC change the async semantics of code produced by the compiler. The changes will bring the semantics more in line with those of dart2js and fix several bugs in the old semantics. However in landing those changes I experienced a test failure in [obscured_animated_image_test](https://github.com/flutter/flutter/blob/master/packages/flutter/test/widgets/obscured_animated_image_test.dart).
Some debugging uncovered that this is due to the use of `SynchronousFuture` in this `FakeCodec`. The old DDC async semantics forced an async gap when that future was [awaited](https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/painting/image_stream.dart#L1064). The new async semantics do not create an async gap here. This changes the render ordering of the widget tree created in the test leading to the test failure.
`Future.value` should be a reasonable substitute here and should achieve what the test was trying to achieve while also preserving the correct render ordering given the new DDC semantics.
This PR rewrites `CupertinoAlertDialog` in a cleaner logic, mostly its layout.
There are two major difficulties to lay out `CupertinoAlertDialog`:
* Laying out the actions section, which switches between a horizontal mode (two buttons in a row) and a vertical mode (several buttons in a column). This PR rewrites it in a special layout widget, `_CupertinoAlertActionSection`.
* Allocating vertical space between the content section and the actions section. This reuses `_PriorityColumn`, which was created for the action sheet.
In a similar fashion to the action sheet, the management and configuration for dividers and background (overscrolls) were rewritten as well.
This PR tries to keep as much original code and behavior as possible since this PR is already very large. As a result, almost no tests are broken. Further improvement will be done in future PRs.
* The test that verifies painting overscrolls is replaced by a golden test, since the original test assumes that the background is painted in one rectangle.
Fixes#150268
The issue was related to the check for selection geometry here: 22a5c6cb0a/packages/flutter/lib/src/widgets/selectable_region.dart (L2469-L2476) . Since `otherList == myList` is a reference check this would fail even if the selection rects inside the list contained in SelectionGeometry where the same causing the selectables inside the selection but outside the selectable containing the tapped position to have their selection cleared, use `listEquals` instead.
Changes:
- Introduced `alignmentOffset` property to `DropdownMenu` to allow adjustment of menu alignment.
- Updated the `MenuAnchor` widget to utilize the new `alignmentOffset` property.
- Default value for `alignmentOffset` is `Offset.zero`, meaning no additional spacing by default.
Motivation:
- This PR closes#151524
- @nate-thegrate, please let me know if I need to make changes in order for this PR to be merged
The motivation behind this change is to provide developers with more control over the spacing between the `MenuAnchor` and `dropdownMenuEntries` in the `DropdownMenu` widget. This enhancement allows for better alignment and customization of the dropdown menu appearance.
| before | after |
| :---: | :---: |
| <img width="372" alt="Screenshot 2024-07-14 at 8 03 14â¯PM" src="https://github.com/user-attachments/assets/4a45b843-7fa4-44fd-843c-c7209c6f57ae"> | <img width="364" alt="Screenshot 2024-07-14 at 8 03 27â¯PM" src="https://github.com/user-attachments/assets/12e8b857-aefb-4aaf-a310-4a002abcbc2f"> |
Initially, it was suggested to use a `SizedBox` to introduce spacing. However, upon further examination of the source code, it was discovered that the `DropdownMenuEntries` are rendered on the screen via an `OverlayPortal`. This necessitated leveraging the existing `alignmentOffset` property within the `MenuAnchor` for a more seamless and effective alignment adjustment.
https://github.com/flutter/flutter/issues/150800
> 2172 out-of-scope references in 138 files, 27 unique symbols were left unresolved.
Only did the most straightforward ones. There will be a part 2.
Reverts: flutter/flutter#152049
Initiated by: cbracken
Reason for reverting: iOS builds failing in post-submit
Original PR Author: loic-sharma
Reviewed By: {jmagman}
This change reverts the following previous change:
Changes:
1. Enables Swift Package Manager by default on the main/master channel
2. Fixes tests that fail if Swift Package Manager is enabled
Corresponding docs change: https://github.com/flutter/website/pull/10938
Addresses https://github.com/flutter/flutter/issues/151567
OverlayPortal attaches its overlaychild's renderobject to overlay directly while keeps its semantics tree under overlayportal.
This become a problem when the `overlaychild` markNeedsSemanticsUpdate that it propagate upward the rendering tree.
This means instead of marking dirty upward to the OverlayPortal, it directly mark Overlay dirty instead and skip `OverlayPortal`.
Currently this does not pose an issue other than unnecessary rebuilds, but it become a problem when I try to optimize the semantics tree compilation https://github.com/flutter/flutter/pull/150394.
After the optimization it won't rebuild semantics node unless it is marked dirty. Since the OverlayPortal widget does not get marked dirty, it won't update the subtree.
This changes the return type from `List<Decoration>` to `List<Decoration?>`, matching the corresponding setter.
As such it is a breaking change.
I believe the current type is a *bug*, and this is the correct fix.
The underlying value has a nullable element type, and the setter accepts a list which can contain `null`, but the getter tries to create a list with non-nullable elements from the stored value.
Calling this getter while the list contains `null` will throw.
(If this fix is too simplistic, I'll file a bug for the issue instead.)
https://github.com/flutter/flutter/issues/150800.
After applying the patch:
```
Can not fully resolve ../../flutter/packages/flutter/lib/src/material/material_state.dart: (MaterialState.pressed, MaterialState.focused, MaterialState.hovered, ..., value, update)
Can not fully resolve ../../flutter/packages/flutter/lib/src/material/material_state_mixin.dart: (MaterialStateProperty.resolve, MaterialState.disabled, MaterialState.dragged, ..., MaterialState.scrolledUnder, MaterialState.selected)
Can not fully resolve ../../flutter/packages/flutter/lib/src/material/reorderable_list.dart: (TargetPlatformVariant.desktop, TargetPlatformVariant.mobile)
Can not fully resolve ../../flutter/packages/flutter/lib/src/material/app.dart: (GlobalMaterialLocalizations)
Can not fully resolve ../../flutter/packages/flutter/lib/src/material/material_localizations.dart: (GlobalMaterialLocalizations)
57 out-of-scope references in 5 files, 22 unique symbols were left unresolved.
```
I'm going to leave `material_state` stuff alone because of https://github.com/flutter/flutter/issues/150800#issuecomment-2243923869,
`TargetPlatformVariant.desktop` requires `flutter_test` and `GlobalMaterialLocalizations` requires `package:flutter_localizations/flutter_localizations.dart`.
Adds an `includeSemantics` property to the Shortcuts widget.
@gspencergoog and I discussed this change to make introducing Shortcuts easier on the MenuAnchor widget. This change should also make testing semantics trees slightly less onerous (assuming this doesn't harm accessibility, that is).
On the point of accessibility, I'm not sure what useful semantic information is exposed by the Shortcuts widget's semantic node, since it's basically just an unfocusable keyboard listener. However, I kept the `includeSemantics` defaulting to true so as to not break semantics tests in the Flutter repo.
Fixes https://github.com/flutter/flutter/issues/152076
When the `"${native_assets_path}"*.framework` glob doesn't resolve anything, the bash will run the loop once with the original unglobbed value: `/path/to/native/assets/*.framework`. Skip this case to prevent the build from failing when there are no frameworks to sign.
To reproduce this build failure:
1. Enable native assets in the Flutter tool: `flutter config --enable-native-assets`
2. Create a Flutter project with the default template: `flutter create test_native_assets`
3. Add a build hook that does nothing (`hook/build.dart`).
4. Try to build/run the app: `flutter run --debug -d macos`
1. Instead of getting the `FULL_PRODUCT_NAME` Xcode build setting (`Runner.app`) instead use `PRODUCT_NAME` since most places really want the product name, and the extension stripping wasn't correct when the name contained periods.
2. Don't instruct the user to open the `xcarchive` in Xcode if it doesn't exist.
Fixes https://github.com/flutter/flutter/issues/140212