24207 Commits

Author SHA1 Message Date
Yegor
54bf532305
Temporarily skip CustomPainter SemanticsFlag test to allow new flag to roll in (#157061)
Same as https://github.com/flutter/flutter/pull/157017, but for `CustomPainter`.
2024-10-16 22:35:23 +00:00
Yegor
4a57ce7932
Temporarily skip SemanticsFlag test to allow new flag to roll in (#157017)
This test relies on the enumeration of all engine flags, and it will fail when https://github.com/flutter/engine/pull/55780 adds `SemanticsFlag.hasSelectedState`. So temporarily skip the test to allow the new flag to be added. I will later unskip the test and change it to check for the new flag as well.

A step towards https://github.com/flutter/flutter/issues/66673
2024-10-16 20:46:16 +00:00
Nate Wilson
8d1ea1e9c5
Monomorphic Mapper (#154972)
This class looks like it _should_ give valid equality checks:

```dart
class _WidgetStateColorMapper extends _WidgetStateColorTransparent {
  const _WidgetStateColorMapper(this.map);

  final WidgetStateMap<Color> map;

  _WidgetStateMapper<Color> get _mapper => _WidgetStateMapper<Color>(map);

  @override
  Color resolve(Set<WidgetState> states) => _mapper.resolve(states);

  @override
  bool operator ==(Object other) {
    return other is _WidgetStateColorMapper && other.map == map;
  }

  @override
  int get hashCode => map.hashCode;
}
```

But I made a mistake: I should have used `other._mapper == _mapper` and `_mapper.hashCode`.

<br>

It'd be pretty nice if no copy-pasting was needed in the first place:

```dart
class _WidgetStateColorMapper extends WidgetStateMapper<Color> implements WidgetStateColor {
  const _WidgetStateColorMapper(super.map);
}
```

<br><br>

This PR makes `WidgetStateMapper` a public class, similar to `WidgetStatePropertyAll`. The new API, when used incorrectly, will `throw` with a detailed error message, rather than silently returning irrelevant values.
2024-10-16 20:18:28 +00:00
Victor Sanni
f9eebe0319
Add bottom to CupertinoNavigationBar to allow for a double-row nav bar (#155959)
Fixes [Support segmented controls in nav bars and double row nav bars](https://github.com/flutter/flutter/issues/10469)

<img width="270" height="600"  alt="Screenshot 2024-09-30 at 3 09 04 PM" src="https://github.com/user-attachments/assets/4003116f-69dd-4f8f-a185-6ca151b74d2d">
2024-10-16 19:36:55 +00:00
LouiseHsu
53bff28f2b
Add a tool warning when pod install does not work after adding a new test/watch/extension/other target with Xcode 16 (#156758)
Running `pod install` on Xcode projects with new test/targets in Xcode 16 will fail. Since this is a [Cocoapods bug](https://github.com/CocoaPods/CocoaPods/issues/12456), this PR adds a warning to the tool that links to a github work around and the current tracking issue.

Fixes https://github.com/flutter/flutter/issues/156733
<img width="567" alt="Screenshot 2024-10-14 at 14 48 39" src="https://github.com/user-attachments/assets/6befa601-4041-46fc-9ca2-f57662adda4a">
2024-10-16 18:58:07 +00:00
Victor Sanni
293ae2e5ab
Add bottom to CupertinoSliverNavigationBar (#155841)
Fixes [Support search box inside large title nav bar](https://github.com/flutter/flutter/issues/18103)
Part of [Support segmented controls in nav bars and double row nav bars](https://github.com/flutter/flutter/issues/10469)

## None mode (Current default)

https://github.com/user-attachments/assets/d798314e-940f-4311-9a9a-fe999c65f280

## Always mode

https://github.com/user-attachments/assets/950a85aa-8ca2-42ea-bf8b-3cb8f95e616e

## Automatic mode

https://github.com/user-attachments/assets/c7c7240b-d493-4036-a987-30f61d02bac3

## With CupertinoSlidingSegmentedControl

https://github.com/user-attachments/assets/59f4aec4-8d9c-4223-915b-97b73cb25dc8

<details>
<summary>Sample Code</summary>

```dart
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/cupertino.dart';

/// Flutter code sample for [CupertinoSliverNavigationBar].

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

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

  @override
  Widget build(BuildContext context) {
    return const CupertinoApp(
      theme: CupertinoThemeData(brightness: Brightness.light),
      home: SliverNavBarExample(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return const CupertinoPageScaffold(
      // A ScrollView that creates custom scroll effects using slivers.
      child: SafeArea(
        child: CustomScrollView(
          // A list of sliver widgets.
          slivers: <Widget>[
            CupertinoSliverNavigationBar(
              leading: SizedBox(
                width: 100,
                child: Row(
                  children: [
                    Icon(CupertinoIcons.back),
                    Text(
                      'Lists',
                      style: TextStyle(color: CupertinoColors.activeBlue),
                    ),
                  ],
                ),
              ),
              trailing: Icon(CupertinoIcons.plus),
              largeTitle: Text('iPhone'),
              // Change to desired mode.
              drawerMode: NavigationDrawerMode.none,
              drawer: Padding(
                padding: EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 16.0),
                child: CupertinoSearchTextField(),
              ),
            ),
            SliverFillRemaining(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Text('Drag me up', textAlign: TextAlign.center),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
```

</details>
2024-10-16 18:25:06 +00:00
Mikhail Novoseltsev
ae6d79336e
[tool] fix android studio preview's version parsing (#156293)
This PR willing to fix issue when `flutter doctor` validator can't determine version of Android Studio EAP.

These are before/after outputs of `flutter doctor -v` showcasing change in behaviour of validator. Each output has 3 `Android Studio` sections, 1 for stable and 2 for different EAP versions. 

<details>
<summary>before, (stable, 3.24.3), 2 issues related to versions of Android Studio</summary>

```console
[✓] Flutter (Channel stable, 3.24.3, on macOS 14.7 23H124 darwin-arm64, locale en-RU)
    • Flutter version 3.24.3 on channel stable at /Users/samer/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (4 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/samer/Library/Android/sdk
    • Platform android-35, build-tools 34.0.0
    • Java binary at: /Users/samer/Library/Java/JavaVirtualMachines/jbr-17.0.7/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment JBR-17.0.7+7-964.1-nomod (build 17.0.7+7-b964.1)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
    • Xcode at /Applications/Xcode-16.0.app/Contents/Developer
    • Build 16A242d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Users/samer/Applications/Android Studio Koala Feature Drop 2024.1.2.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[!] Android Studio (version unknown)
    • Android Studio at /Users/samer/Applications/Android Studio Ladybug Feature Drop 2024.2.2 Canary 2.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

[!] Android Studio (version unknown)
    • Android Studio at /Users/samer/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

[✓] IntelliJ IDEA Ultimate Edition (version EAP IU-243.12818.47)
    • IntelliJ at /Users/samer/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.94.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.98.0

[✓] Connected device (5 available)
    • sdk gphone64 arm64 (mobile)     • emulator-5554             • android-arm64  • Android 15 (API 35) (emulator)
    • iPhone (Михаил) (mobile)        • 00008020-001254DA1E39002E • ios            • iOS 17.6.1 21G93
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.7 23H124 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.7 23H124 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 129.0.6668.90
    ! Error: Browsing on the local area network for Михаил Новосельцев’s iPad. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.
```
</details>

<details>
<summary>after,  no issues regarding Android Studio</summary>

```console
[!] Flutter (Channel [user-branch], 3.26.0-1.0.pre.383, on macOS 14.7 23H124 darwin-arm64, locale en-RU)
    ! Flutter version 3.26.0-1.0.pre.383 on channel [user-branch] at /Users/samer/projects/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    • Upstream repository git@github.com:Sameri11/flutter.git
    • FLUTTER_GIT_URL = git@github.com:Sameri11/flutter.git
    • Framework revision 852508425d (20 minutes ago), 2024-10-07 21:22:45 +0500
    • Engine revision 683a14c1f1
    • Dart version 3.6.0 (build 3.6.0-326.0.dev)
    • DevTools version 2.40.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update
      checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/samer/Library/Android/sdk
    • Platform android-35, build-tools 34.0.0
    • Java binary at: /Users/samer/Library/Java/JavaVirtualMachines/jbr-17.0.7/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment JBR-17.0.7+7-964.1-nomod (build 17.0.7+7-b964.1)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
    • Xcode at /Applications/Xcode-16.0.app/Contents/Developer
    • Build 16A242d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Users/samer/Applications/Android Studio Koala Feature Drop 2024.1.2.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] Android Studio (version 2024.2.2)
    • Android Studio at /Users/samer/Applications/Android Studio Ladybug Feature Drop 2024.2.2 Canary 2.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

[✓] Android Studio (version 2024.2.1)
    • Android Studio at /Users/samer/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

[✓] IntelliJ IDEA Ultimate Edition (version EAP IU-243.12818.47)
    • IntelliJ at /Users/samer/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.94.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.98.0

[✓] Connected device (5 available)
    • sdk gphone64 arm64 (mobile)     • emulator-5554             • android-arm64  • Android 15 (API 35) (emulator)
    • iPhone (Михаил) (mobile)        • 00008020-001254DA1E39002E • ios            • iOS 17.6.1 21G93
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.7 23H124 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.7 23H124 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 129.0.6668.90
    ! Error: Browsing on the local area network for Михаил Новосельцев’s iPad. Ensure the device is unlocked and attached with a cable or
      associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
```
</details>

Logic behind these changes explained in https://github.com/flutter/flutter/issues/121925#issuecomment-2352826925 

fixes #121925

**Tests**: updated existing tests by adding version checking, but I don't mind writing new ones if necessary – please tell me if so.
2024-10-16 15:56:31 +00:00
Jakub Bogacki
279d30a44f
Add TapOutsideConfiguration widget (#150125)
This PR adds `TapOutsideConfiguration` where you can define a custom default logic for `onTapOutside`.

```dart
TapOutsideConfiguration(
  behavior: AlwaysUnfocusTapOutsideBehavior(),
  // behavior: const NeverUnfocusTapOutsideBehavior(),
  // behavior: const CustomTapOutsideBehavior(),
  child: Column(
    children: [
      // This TextField will use onTapOutside from TapOutsideConfiguration
      TextField(),
      // Of course you can still define onTapOutside
      TextField(onTapOutside: (event) => print('Tapped outside')),
    ],
  ),
)
```

Custom logic can be define like this:

```dart
class CustomTapOutsideBehavior extends TapOutsideBehavior {
  const CustomTapOutsideBehavior();

  @override
  void defaultOnTapOutside(PointerDownEvent event, FocusNode focusNode) {
    // any custom logic here
  }
}
```

This PR implements also two simple `AlwaysUnfocusTapOutsideBehavior` and `NeverUnfocusTapOutsideBehavior`.

Resolves #150123
2024-10-16 13:25:34 +00:00
Bruno Leroux
2430f00a01
fix DropdownMenu keyboard navigation is broken when expandedInsets is set (#156803)
## Description

This PR fixes keyboard navigation when `DropdownMenu.expandedInsets` is used.
Before this PR the Shortcuts widget defining the navigation intents was only added when `DropdownMenu.expandedInsets` was null.
After this PR, the Shortcuts widget is always added.

## Related Issue

Fixes [DropdownMenu keyboard navigation is broken when expandedInsets is set](https://github.com/flutter/flutter/issues/156712).

## Tests

Adds 2 tests.
Replaces several unneeded 'pumpAndSettle'.
2024-10-16 07:30:34 +00:00
Loïc Sharma
4d48c60b57
Pin google_mobile_ads to 5.1.0 (#156911)
`google_mobile_ads` 5.2.0 is known to break the builds of Flutter apps: https://github.com/googleads/googleads-mobile-flutter/issues/1193

This pins google_mobile_ads to 5.1.0 to unblock the pub autoroller.

See: https://github.com/flutter/flutter/issues/156606
2024-10-15 22:36:09 +00:00
Siva
4715296249
Fix JS compilation to use the command 'compile js' instead of using snapshot names to invoke dart2js (#156735)
Fix JS compilation to use the command 'compile js' instead of using
snapshot names to invoke dart2js

The Dart SDK is switching all tools to use AOT snapshots instead of JIT
snapshots and using snapshot names directly causes things to break.
2024-10-15 15:28:27 -07:00
Jason Simmons
4f2211b550
Determine the scroll gesture axis based on the effectiveScrollController (#156190)
Fixes https://github.com/flutter/flutter/issues/154520
2024-10-15 20:58:51 +00:00
Rexios
e96aaab5e0
Add padding options to SearchAnchor (#152508)
Cherry-picked padding changes from https://github.com/flutter/flutter/pull/148856

Adds padding configuration options to `SearchAnchor`. This PR adds the following:
- `viewBarPadding`: The padding for items inside the `SearchBar` in the `SearchAnchor` view
- `viewPadding`: The padding to use around the entire `SearchAnchor` view

Working towards https://github.com/flutter/flutter/issues/148852
2024-10-15 20:24:48 +00:00
Andrew Kolos
2dad95b21c
Fix flavor-conditional asset bundling for path dependencies (#156687)
Fixes https://github.com/flutter/flutter/issues/155755

When building the asset bundle during, the `--flavor` option isn't considered when searching for assets from dependencies. This PR fixes that.

It's possible that when initially implementing this feature, I thought that flavor-conditional assets didn't make sense for packages. While I still think that way regarding pub packages, using this feature makes a lot more sense for monorepo projects.

<details>

<summary> Pre-launch checklist </summary> 

</details>
2024-10-15 17:39:01 +00:00
Victor Sanni
915985ad52
Implement CupertinoSearchTextField opacity fade on scroll (#155025)
## Before:

https://github.com/user-attachments/assets/38cabba1-d002-4a5d-b80b-fd0955b2aad5

## After:

https://github.com/user-attachments/assets/3e73f863-c353-43f3-90b8-fd322b42b5d3

## Native iOS:

https://github.com/user-attachments/assets/daab345e-09ae-44dc-a1a0-461757c13542

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

Needed for https://github.com/flutter/flutter/issues/18103
2024-10-15 17:03:25 +00:00
Ben Konyi
ad370c8fa7
[ Tool ] Support Powershell v6+ to determine Windows version in flutter doctor (#156476)
Powershell v6+ use the executable name `pwsh.exe` instead of
`powershell.exe`. This change adds support for determining the Windows
version on systems that solely use `pwsh.exe` and don't have
`powershell.exe` on the `PATH`.

Fixes #156189.

---------

Co-authored-by: Andrew Kolos <andrewrkolos@gmail.com>
2024-10-15 11:48:35 -04:00
Taha Tesser
8ea38a7921
Fix AppBar back button doesn't navigate back when using TooltipTriggerMode.tap in the TooltipTheme (#155822)
Fixes [AppBar BackButton Tooltip interferes with clicking button when TooltipThemeData set to TooltipTriggerMode.tap](https://github.com/flutter/flutter/issues/152315)

### Description
`TooltipTheme` with `triggerMode: TooltipTriggerMode.tap` prevents user from navigating back when tapping on the back button. `triggerMode: TooltipTriggerMode.tap` shouldn't interrupted the back button navigation back callback.

### 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(
        tooltipTheme:
            const TooltipThemeData(triggerMode: TooltipTriggerMode.tap),
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Sample'),
        ),
        body: Builder(builder: (context) {
          return Center(
            child: ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => const SecondScreen(),
                  ),
                );
              },
              child: const Text('Go to Second Screen'),
            ),
          );
        }),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Second Screen'),
      ),
      body: const Center(
        child: Tooltip(
          message: 'This is the second screen',
          child: Text('Tap to show tooltip'),
        ),
      ),
    );
  }
}
```

</details>

### Before

https://github.com/user-attachments/assets/ed2020f0-aef8-40f9-be05-55ff80e42e5d

### After

https://github.com/user-attachments/assets/8d65f9f8-d15d-453f-955f-e5d92f8a04e8
2024-10-15 12:30:28 +00:00
Hannah Jin
75d93e1c44
Update dropdown menu semantics to fix its a11y issues (#156709)
fixes https://github.com/flutter/flutter/issues/133742 

because the _initialMenu is invisible, we should not add semantics nodes
to it

## 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].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] 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/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#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/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
2024-10-14 13:36:24 -07:00
Bruno Leroux
a60933551d
Refactor some DropdownMenu tests (#156702)
## Description

This PR adds a utility method, named `isItemHighlighted`, to simplify several `DropdownMenu` tests.
It will help for some inworking changes.
2024-10-14 20:17:09 +00:00
Jatin Nagar
b3491acb0d
RadioListTile: add property to scale the radio (#156292)
Added a property in the RadioListTile to scale the underlying Radio using `Transform.scale`.

Fixes: #81334
2024-10-12 15:50:36 +00:00
Viraj Kanwade
0eedec47c2
Updated iPhone enable developer mode instructions (#154511)
The instructions specify to enable Developer Mode in Privacy and Security. But Developer Mode option is not available, unless you open Xcode and reconnect the device.

___________
9/23 edit from @andrewkolos: See https://stackoverflow.com/questions/77648341/flutter-not-reading-device-developer-mode-setting
2024-10-12 06:23:13 +00:00
Jatin Nagar
63dd042e72
CheckboxListTile: use Transform.scale only when required (#156593)
Make CheckboxListTile use `Transform.scale` only when required.

Fixes: #81334
2024-10-12 05:37:38 +00:00
Bruno Leroux
9e64b67111
Improve InputDecoration.errorMaxLines documentation (#156468)
## Description

This PR improves the `InputDecoration.errorMaxLines` and `InputDecoration.helperMaxLines` documentations to explain when wrapping and ellipsing are applied.

## Related Issue

Fixes [InputDecoration.errorMaxLines's documentation does not match behavior](https://github.com/flutter/flutter/issues/155626).
2024-10-11 21:35:27 +00:00
RamonFarizel
51aa2f5809
Add code sample to the CupertinoMagnifier/CupertinoTextMagnifier (#156028)
This PR adds code samples regarding the CupertinoMagnifier and CupertinoTextMagnifier

Fixes #154439
2024-10-11 20:53:18 +00:00
Taha Tesser
45033a29f9
Introduce DropdownMenu.closeBehavior to control menu closing behavior (#156405)
Fixes [Add option to control whether the root DropdownMenu can be closed or not](https://github.com/flutter/flutter/issues/139269)

This introduces  `DropdownMenu.closeBehavior` to provide control over `DropdownMenu` can be closed in nested menus.

### 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 StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String selectedValue = "1";

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: [
              Column(
                spacing: 16.0,
                mainAxisSize: MainAxisSize.min,
                children: [
                  const Text("DropdownMenuCloseBehavior.none"),
                  MenuAnchor(
                    menuChildren: <Widget>[
                      Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: DropdownMenu(
                          closeBehavior: DropdownMenuCloseBehavior.none,
                          label: const Text('Menu'),
                          initialSelection: selectedValue,
                          onSelected: (String? value) {
                            if (value != null) {
                              setState(() {
                                selectedValue = value;
                              });
                            }
                          },
                          dropdownMenuEntries: ["1", "2", "3"]
                              .map(
                                (it) => DropdownMenuEntry(
                                  value: it,
                                  label: it,
                                ),
                              )
                              .toList(),
                        ),
                      )
                    ],
                    child: const Text('Open Menu'),
                    builder: (context, controller, child) {
                      return ElevatedButton(
                        onPressed: () {
                          controller.open();
                        },
                        child: child,
                      );
                    },
                  ),
                ],
              ),
              Column(
                spacing: 16.0,
                mainAxisSize: MainAxisSize.min,
                children: [
                  const Text("DropdownMenuCloseBehavior.self"),
                  MenuAnchor(
                    menuChildren: <Widget>[
                      Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: DropdownMenu(
                          closeBehavior: DropdownMenuCloseBehavior.self,
                          label: const Text('Menu'),
                          initialSelection: selectedValue,
                          onSelected: (String? value) {
                            if (value != null) {
                              setState(() {
                                selectedValue = value;
                              });
                            }
                          },
                          dropdownMenuEntries: ["1", "2", "3"]
                              .map(
                                (it) => DropdownMenuEntry(
                                  value: it,
                                  label: it,
                                ),
                              )
                              .toList(),
                        ),
                      )
                    ],
                    child: const Text('Open Menu'),
                    builder: (context, controller, child) {
                      return ElevatedButton(
                        onPressed: () {
                          controller.open();
                        },
                        child: child,
                      );
                    },
                  ),
                ],
              ),
              Column(
                spacing: 16.0,
                mainAxisSize: MainAxisSize.min,
                children: [
                  const Text("DropdownMenuCloseBehavior.all"),
                  MenuAnchor(
                    menuChildren: <Widget>[
                      Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: DropdownMenu(
                          closeBehavior: DropdownMenuCloseBehavior.all,
                          label: const Text('Menu'),
                          initialSelection: selectedValue,
                          onSelected: (String? value) {
                            if (value != null) {
                              setState(() {
                                selectedValue = value;
                              });
                            }
                          },
                          dropdownMenuEntries: ["1", "2", "3"]
                              .map(
                                (it) => DropdownMenuEntry(
                                  value: it,
                                  label: it,
                                ),
                              )
                              .toList(),
                        ),
                      )
                    ],
                    child: const Text('Open Menu'),
                    builder: (context, controller, child) {
                      return ElevatedButton(
                        onPressed: () {
                          controller.open();
                        },
                        child: child,
                      );
                    },
                  ),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}
```

</details>

### Demo

https://github.com/user-attachments/assets/1f79ea6e-c0c6-4dcf-8180-d9dcca1c22c5
2024-10-11 20:51:18 +00:00
auto-submit[bot]
c1a301e8e8
Reverts "Manual pub roll (#156549)" (#156607)
Reverts: flutter/flutter#156549
Initiated by: christopherfujino
Reason for reverting: https://github.com/flutter/flutter/issues/156606
Original PR Author: christopherfujino

Reviewed By: {matanlurey}

This change reverts the following previous change:
I manually ran:

```
flutter update-packages --force-upgrade
cd dev/tools && dart bin/generate_gradle_lockfiles.dart --no-gradle-generation --no-exclusion
```

Note this bumps the `google_mobile_ads` plugin, which caused https://github.com/flutter/flutter/issues/156474. I expect it to work this time after https://flutter-review.googlesource.com/c/recipes/+/60340
2024-10-11 18:52:18 +00:00
Christopher Fujino
184deff0f2
Manual pub roll (#156549)
I manually ran:

```
flutter update-packages --force-upgrade
cd dev/tools && dart bin/generate_gradle_lockfiles.dart --no-gradle-generation --no-exclusion
```

Note this bumps the `google_mobile_ads` plugin, which caused https://github.com/flutter/flutter/issues/156474. I expect it to work this time after https://flutter-review.googlesource.com/c/recipes/+/60340
2024-10-11 17:57:36 +00:00
Sam Rawlins
e1dd322c8d
Add doc-import for references to CommonFinders (#156539)
This adds back in the doc comment references for `CommonFinders` that
caused CI issues when @gspencergoog was trying to land
https://github.com/flutter/flutter/pull/149349.

This essentially reverts
a7721fe489.
2024-10-10 20:04:06 -07:00
John McDole
9a9b9218ee
Flutter tool assumes impeller is enabled by default (#156540)
... because it is.
2024-10-10 18:44:18 +00:00
stuartmorgan
e8254b2024
Update Android plugin templates for newer AGP (#156533)
Now that Flutter requires AGP 7+, we can use Java 11 as the compatibility version in the plugin template rather than 1.8, avoiding warnings with newer toolchains, and we can remove the check for 'namespace' existing that was only necessary to support AGP 4.1.

See also https://github.com/flutter/packages/pull/7795 which made this change in Flutter-team-owned plugins.

Part of https://github.com/flutter/flutter/issues/156111
2024-10-10 17:18:50 +00:00
Daco Harkes
225e4aabb5
Flutter templates example app Gradle memory settings (#156201)
Adding even more memory to see if it addresses flakes:

* https://github.com/flutter/flutter/issues/156063#issuecomment-2388949557
2024-10-10 16:02:11 +00:00
Harry Terkelsen
810c87a2e3
[canvaskit] Unskip cupertino datepicker tests (#156499)
Unskips Cupertino Datepicker tests on CanvasKit.

Addresses https://github.com/flutter/flutter/issues/110785 for CanvasKit. But the tests are still failing for Skwasm.
2024-10-10 15:50:19 +00:00
auto-submit[bot]
0403c1cb8f
Reverts "Roll pub packages (#156440)" (#156473)
Reverts: flutter/flutter#156440
Initiated by: zanderso
Reason for reverting: Failing in post submit with
```
[2024-10-08 18:00:22.743647] [STDOUT] stdout:                [!] CocoaPods could not find compatible versions for pod "Google-Mobile-Ads-SDK":
[2024-10-08 18:00:22.743695] [STDOUT] stdout:                  In Podfile:
[2024-10-08 18:00:22.743718] [STDOUT] stdout:                    google_mobile_ads (from `.symlinks/plugins/google_mobile_ads/ios`) was resolved t
Original PR Author: flutter-pub-roller-bot

Reviewed By: {fluttergithubbot}

This change reverts the following previous change:
This PR was generated by `flutter update-packages --force-upgrade`.
2024-10-09 13:45:47 +00:00
flutter-pub-roller-bot
f96d1618c4
Roll pub packages (#156440)
This PR was generated by `flutter update-packages --force-upgrade`.
2024-10-08 23:28:01 +00:00
Kevin Moore
a80c3823f5
[tool] Update description of where to install platforms in XCode (#156432)
Fixes https://github.com/flutter/flutter/issues/156431
2024-10-08 21:34:22 +00:00
Qun Cheng
e317860b35
Normalize ThemeData.tabBarTheme (#156253)
Following https://github.com/flutter/flutter/pull/155476, this PR is to normalize `ThemeData.tabBarTheme`; change the `TabBarTheme tabBarTheme` property to `TabBarThemeData tabBarTheme` in `ThemeData`. In `ThemeData()` and `ThemeData.copyWith()`, the `tabBarTheme` parameter type is changed to `Object?` to accept both `TabBarTheme` and `TabBarThemeData` so that we won't cause immediate breaking change and make sure rolling is smooth. Once all component themes are normalized, these `Object?` types should be changed to `xxxThemeData`.

There's no way to create a dart fix because we can't add a "@deprecated" label for TabBarTheme; TabBarTheme is a new InheritedWidget subclass now.

Addresses the "theme normalization" sub project within https://github.com/flutter/flutter/issues/91772
2024-10-08 19:52:38 +00:00
Adam
37d5dc45d1
Add bySemanticsIdentifier finder for finding by identifier (#155571)
## Add `bySemanticsIdentifier` finder for finding by identifier

### Description

This pull request introduces a new finder, `CommonFinders.bySemanticsIdentifier`, to the Flutter testing framework. This finder allows developers to locate `Semantics` widgets based on their `identifier` property, enhancing the precision and flexibility of widget tests.

### Motivation

Establish a consistent and reliable method for locating elements in integration and end-to-end (e2e) tests. Unlike `label` or `key`, which may carry functional significance within the application, the `identifier` is purely declarative and does not impact functionality. Utilizing the `identifier` for finding semantics widgets ensures that tests can target specific elements without interfering with the app's behavior, thereby enhancing test reliability, maintainability, and reusability across testing frameworks.

### Changes

- **semantics.dart**
  - Updated documentation to mention that `identifier` can be matched using `CommonFinders.bySemanticsIdentifier`.
  
- **finders.dart**
  - Added the `bySemanticsIdentifier` method to `CommonFinders`.
  - Supports both exact string matches and regular expression patterns.
  - Includes error handling to ensure semantics are enabled during tests.
  
- **finders_test.dart**
  - Added tests to verify that `bySemanticsIdentifier` correctly finds widgets by exact identifier and regex patterns.
  - Ensures that the finder behaves as expected when semantics are not enabled.

### Usage

Developers can use the new finder in their tests as follows:

```dart
// Exact match
expect(find.bySemanticsIdentifier('Back'), findsOneWidget);

// Regular expression match
expect(find.bySemanticsIdentifier(RegExp(r'^item-')), findsNWidgets(2));
```
2024-10-08 17:27:32 +00:00
PurplePolyhedron
138144bb2f
Update DropdownMenu tests to remove some dependence on platforms (#156131)
Keyboard navigation in  `DropdownMenu` depends on `focus` instead of platforms.
Updating tests to remove `variant: TargetPlatformVariant.desktop()`  from keyboard navigation tests.
2024-10-08 15:55:18 +00:00
Justin McCandless
22635e19c1
NavigatorPopHandler.onPopWithResult (#155618)
NavigatorPopHandler now includes the return value from Route. Recently some navigation infrastructure was updated to support passing through these return values, but NavigatorPopHandler was missed until now.
2024-10-08 08:19:29 -07:00
Daco Harkes
e695cd6e9a
Migrator for android 35/16kb page size cmake flags for plugin_ffi (#156221)
Migrates existing instantions of `--template plugin_ffi` to deal with Android 15 16kb memory pages.

Issue:

* https://github.com/flutter/flutter/issues/155933

@reidbaker I could only find migrations that run from the root application. However the file needing to be migrated is a plugin. The plugin is being referenced from the example in the example dir and that's where the migrator is run, so I wrote the code so that it walks up to find the plugin. Do you know of a way to run migrators to non-root projects? (Can we even safely do so, e.g. the non-root could be in the pub cache, could be a different project on the users' system etc. So maybe checking if we are in the examples dir is the only sane thing to do?)

Tests:

* Added unit tests in `test/general.shard/android/migrations/cmake_android_16k_pages_migration_test.dart`
2024-10-08 08:41:09 +00:00
Taha Tesser
44f7c6913f
Update flexible_space_bar_test.dart tests for Material 3 (#156226)
Updated unit tests for `FlexibleSpaceBar` to have M2 and M3 versions.

More info in #139076
2024-10-08 07:42:08 +00:00
David Iglesias
d744da18e5
[tool] Emit a deprecation warning for some values of --web-renderer. (#156376)
This PR emits a blue warning text when using `flutter ... --web-renderer=html|auto`.

(The message is similar to the one that we emit at run-time)

## Issues

Fixes https://github.com/flutter/flutter/issues/154878
See also: https://github.com/flutter/engine/pull/55709
2024-10-08 01:39:06 +00:00
Mairramer
56a33efd73
Fixes an issue where onTapOutside was incorrectly triggered across routes in TapRegion (#155297)
Fixes https://github.com/flutter/flutter/issues/153093

This PR fixes the issue of onTapOutside being triggered on other routes incorrectly.
2024-10-07 20:48:00 +00:00
Nate Biggs
da71e6e93d
Update 'dump-info' usage for dart2js builds (#156187)
Dart2js updated its CLI to support generating a 'dump-info' json file by passing a "--stage" option. The "dump-info-all" stage performs a full compilation (from the provided dill) and then also generates the dump info file.

Tested via the `flutter-dev` CLI locally. This results in the same output but with the addition of an extra `main.dart.js.info.json` file.
2024-10-07 20:06:18 +00:00
Andrew Kolos
e96c47f953
handle any RPCError due to vm service disconnection in flutter run (#156346)
Follow-up to https://github.com/flutter/flutter/pull/153714. While reading through run.dart, I noticed we missed a case.
2024-10-07 18:48:22 +00:00
Taha Tesser
b3de00ad54
Fix DropdownMenu with expandedInsets always aligned on top (#156214)
Fixes [DropdownMenu can not be center aligned when using expandedInsets
](https://github.com/flutter/flutter/issues/155581)

### 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) {
    final List<DropdownMenuEntry<ShortMenu>> shortMenuItems =
        <DropdownMenuEntry<ShortMenu>>[];
    for (final ShortMenu value in ShortMenu.values) {
      final DropdownMenuEntry<ShortMenu> entry =
          DropdownMenuEntry<ShortMenu>(value: value, label: value.label);
      shortMenuItems.add(entry);
    }

    return MaterialApp(
      home: Scaffold(
        body: Row(
          children: <Widget>[
            Expanded(
              child: Center(
                child: DropdownMenu<ShortMenu>(
                  expandedInsets: const EdgeInsets.all(16),
                  initialSelection: ShortMenu.item0,
                  dropdownMenuEntries: shortMenuItems,
                  label: const Text('With expandedInsets'),
                ),
              ),
            ),
            Expanded(
              child: Center(
                child: DropdownMenu<ShortMenu>(
                  initialSelection: ShortMenu.item0,
                  dropdownMenuEntries: shortMenuItems,
                  label: const Text('Without expandedInsets'),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

enum ShortMenu {
  item0('Menu 0'),
  item1('Menu 1'),
  item2('Menu 2');

  const ShortMenu(this.label);
  final String label;
}
```

</details>

### Before 
(`DropdownMenu` without `expandedInsets` cannot be centered)
<img width="770" alt="Screenshot 2024-10-04 at 14 13 58" src="https://github.com/user-attachments/assets/c7520c12-d16a-4867-8fae-38b75dbc4225">

### After
(`DropdownMenu` with `expandedInsets` be centered)

<img width="770" alt="Screenshot 2024-10-04 at 14 13 49" src="https://github.com/user-attachments/assets/82e0b81e-5c85-4e59-99b8-df329459773b">
2024-10-07 13:43:22 +00:00
Jatin Nagar
bae7971431
CheckboxListTile: add property to scale the checkbox (#154806)
Added a property in the CheckboxListTile to scale the underlying Checkbox using `Transform.scale`.

Fixes: #81334
2024-10-06 14:49:20 +00:00
Qun Cheng
534adfbe02
Normalize ThemeData.cardTheme (#153254)
Following https://github.com/flutter/flutter/pull/151914, this PR is to normalize `ThemeData.cardTheme`; change the `CardTheme cardTheme` property to `CardThemeData cardTheme` in `ThemeData`. In `ThemeData()` and `ThemeData.copyWith()`, the `cardTheme` parameter type is changed to `Object?` to accept both `CardTheme` and `CardThemeData` so that we won't cause immediate breaking change and make sure rolling is smooth. Once all component themes are normalized, these `Object?` types should be changed to `xxxThemeData`.

There's no way to create a dart fix because we can't add a "@deprecated" label for `CardTheme` because `CardTheme` is a new InheritedWidget subclass now.

Addresses the "theme normalization" sub project within https://github.com/flutter/flutter/issues/91772
2024-10-04 18:59:05 +00:00
Nate Wilson
5bfc3d43ae
Refactor devfs_web_ddc_modules_test.dart (#155609)
This pull request adds a local function `runInTestbed()` to **devfs_web_ddc_modules_test.dart**, which wraps the `testbed.run()` method. Several whitespace adjustments have been made as well.

<br>

It's much easier to read after clicking "hide whitespace".

<br>

Relevant style guidelines:
- Prefer avoiding line breaks after assignment operators.
- If you have a newline after some opening punctuation, match it on the closing punctuation.
- Only use `=>` when everything, including the function declaration, fits on a single line.
2024-10-03 21:10:03 +00:00
Tong Mu
59e57437db
Allow arrow keys to navigate MenuAnchor independently of global shortcut definition (#155728)
This PR adjusts the implementation of handling navigational shortcuts (i.e. arrow keys) on `MenuAnchor` and `DropdownMenu`.

## Motivation
The direct outcome of this PR is to allow keyboard to enter submenus on Web: When the focus is on a `MenuAnchor` while the menu is open, pressing arrow keys should move the focus to the menu item.
* Before the PR, this works for all platforms but Web, a problem described in https://github.com/flutter/flutter/issues/119532#issuecomment-2274705565.

It is caused by the fact that `MenuAnchor` does not wrap itself with a `Shortcuts`, and therefore key events when the focus is on a `MenuAnchor` has been working only because the event falls back to the `Shortcuts` widget defined by `WidgetsApp`, whose default value happens to satisfy `MenuAnchor`'s needs - except on Web where arrow keys are defined to scroll instead of traverse. 

Instead of defining this problem as "just a patch for Web", I think it's better to define it as a problem of all platforms: `MenuAnchor`'s shortcuts should be independent of `WidgetsApp.shortcuts`. Because even if `WidgetsApp.shortcuts` is redefined as something else, people should probably still expect arrow keys to work on `MenuAnchor`.

Therefore this PR makes `MenuAnchor` produce a `Shortcuts` by itself.

### Dropdown menu
The fix above breaks `DropdownMenu`. `DropdownMenu` uses `MenuAnchor`, while defining its own shortcuts because, when filter is enabled:
* The left and right arrow keys need to move the text carets instead
* The up and down arrow keys need to "fake" directional navigation - the focus needs to stay on the text field, while some menu item is highlighted as if it is focused.

Before the PR, `DropdownMenu` defines these shortcuts out of `MenuAnchor`. In order for the `DropdownMenu`'s shortcuts to take priority, these shortcuts are moved to between `MenuAnchor` and the `Textfield`.

A test is added to verify that the left/right keys move text carets.

Below are psuedo-widget-trees after the PR:
```
MenuAnchor
 |- Shortcuts(arrows->DirectionalFocusIntent)
    |- MenuAnchor.child
    |- menu

DropdownMenu
 |- Actions(DirectionalFocusIntent->_dropdownMenuNavigation)
    |- MenuAnchor
        |- Shortcuts(arrows->DirectionalFocusIntent)
            |- Shortcuts(leftright->ExtendSelectionByCharacterIntent, updown->_dropdownMenuArrowIntent)
            |  |- TextField
            |     |- EditableText
            |        |- Actions(DirectionalFocusIntent->DirectionalFocusAction.forTextField)
            |- menu
```

## Known issues
After this PR, traversing the menu still have quite a few problems, which are left for other PRs.
2024-10-03 20:09:19 +00:00