12535 Commits

Author SHA1 Message Date
Jonah Williams
253bd3d475
[framework] lerp images in a save layer. (#131703)
Without a saveLayer, the BlendMode.plus will add itself to the backdrop and not just the previous image. Pushing without tests to see if existing goldens fail, but otherwise I have some good examples locally.

This is necessary uncondtionally, and lerping lerped images has the same issue.

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

### Before

![flutter_02](https://github.com/flutter/flutter/assets/8975114/1e783285-2fc2-429f-9fd8-6d04d4a155e1)

### After

![flutter_03](https://github.com/flutter/flutter/assets/8975114/3d08b187-26aa-4471-926d-e9ed5946a206)
2023-08-02 19:51:41 +00:00
Dan Field
b3f99ffe61
Fix reentrancy with WidgetBindingObserver callbacks (#131774)
Part of https://github.com/flutter/flutter/issues/131678

Fixes up callsites for WidgetsBindingObserver related callbacks.
2023-08-02 17:29:50 +00:00
Kate Lovett
a120342922
Fix flex methods for min and max column widths (#131724)
Fixes https://github.com/flutter/flutter/issues/131467

An error in the flex methods of min and max column width would produce different results based on the position of the widths that were provided:
`MaxColumnWidth(a, b) != MaxColumnWidth(b, a)`

This fixes that.
2023-08-02 17:00:48 +00:00
fzyzcjy
4b176a716c
Tiny remove outdated comments (#130387)
I get confused when reading this comment. It seems that this code never calls `AnimationController.fling` (but only things like `animateTo`). Therefore, I do not think discussing the duration of `AnimationController.fling` is helpful - maybe it is just an outdated comment?
2023-08-02 16:21:54 +00:00
Daniel Chevalier
f80ff55a76
Fix for endless recursion for getLayoutExplorerNode on a Tooltip (#131486)
![](https://media.giphy.com/media/l0ExdBwqD6YkeEhQ4/giphy-downsized.gif)

Fixes https://github.com/flutter/devtools/issues/5946

While preparing DevTools for the Multi View changes, I noticed that
inspecting a Tooltip causes an stack overflow.
This PR addresses that issue by fixing the scope of the subtreeDepth variable and adding some other idiomatic fixes
2023-08-02 09:23:57 -04:00
LiangXiang Shen
c51aa3d2de
Update ThemeData's factory method documents (#123984)
Catch up document. As Material 3 actually use a purple theme.

d8cbaf6261/packages/flutter/lib/src/material/theme_data.dart (L2777-L2856)
2023-08-02 03:42:06 +00:00
Taha Tesser
2c71881f50
Fix Scrollable TabBar for Material 3 (#131409)
fixes [Material 3 `TabBar` does not take full width when `isScrollable: true`](https://github.com/flutter/flutter/issues/117722)

### Description
1. Fixed the divider doesn't stretch to take all the available width in the scrollable tab bar in M3
2. Added `dividerHeight` property.

### Code sample

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

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

/// Flutter code sample for [TabBar].

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: TabBarExample(),
    );
  }
}

class TabBarExample extends StatefulWidget {
  const TabBarExample({super.key});

  @override
  State<TabBarExample> createState() => _TabBarExampleState();
}

class _TabBarExampleState extends State<TabBarExample> {
  bool rtl = false;
  bool customColors = false;
  bool removeDivider = false;
  Color dividerColor = Colors.amber;
  Color indicatorColor = Colors.red;

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      initialIndex: 1,
      length: 3,
      child: Directionality(
        textDirection: rtl ? TextDirection.rtl : TextDirection.ltr,
        child: Scaffold(
          appBar: AppBar(
            title: const Text('TabBar Sample'),
            actions: <Widget>[
              IconButton.filledTonal(
                tooltip: 'Switch direction',
                icon: const Icon(Icons.swap_horiz),
                onPressed: () {
                  setState(() {
                    rtl = !rtl;
                  });
                },
              ),
              IconButton.filledTonal(
                tooltip: 'Use custom colors',
                icon: const Icon(Icons.color_lens),
                onPressed: () {
                  setState(() {
                    customColors = !customColors;
                  });
                },
              ),
              IconButton.filledTonal(
                tooltip: 'Show/hide divider',
                icon: const Icon(Icons.remove_rounded),
                onPressed: () {
                  setState(() {
                    removeDivider = !removeDivider;
                  });
                },
              ),
            ],
          ),
          body: Column(
            children: <Widget>[
              const Spacer(),
              const Text('Scrollable - TabAlignment.start'),
              TabBar(
                isScrollable: true,
                tabAlignment: TabAlignment.start,
                dividerColor: customColors ? dividerColor : null,
                indicatorColor: customColors ? indicatorColor : null,
                dividerHeight: removeDivider ? 0 : null,
                tabs: const <Widget>[
                  Tab(
                    icon: Icon(Icons.cloud_outlined),
                  ),
                  Tab(
                    icon: Icon(Icons.beach_access_sharp),
                  ),
                  Tab(
                    icon: Icon(Icons.brightness_5_sharp),
                  ),
                ],
              ),
              const Text('Scrollable - TabAlignment.startOffset'),
              TabBar(
                isScrollable: true,
                tabAlignment: TabAlignment.startOffset,
                dividerColor: customColors ? dividerColor : null,
                indicatorColor: customColors ? indicatorColor : null,
                dividerHeight: removeDivider ? 0 : null,
                tabs: const <Widget>[
                  Tab(
                    icon: Icon(Icons.cloud_outlined),
                  ),
                  Tab(
                    icon: Icon(Icons.beach_access_sharp),
                  ),
                  Tab(
                    icon: Icon(Icons.brightness_5_sharp),
                  ),
                ],
              ),
              const Text('Scrollable - TabAlignment.center'),
              TabBar(
                isScrollable: true,
                tabAlignment: TabAlignment.center,
                dividerColor: customColors ? dividerColor : null,
                indicatorColor: customColors ? indicatorColor : null,
                dividerHeight: removeDivider ? 0 : null,
                tabs: const <Widget>[
                  Tab(
                    icon: Icon(Icons.cloud_outlined),
                  ),
                  Tab(
                    icon: Icon(Icons.beach_access_sharp),
                  ),
                  Tab(
                    icon: Icon(Icons.brightness_5_sharp),
                  ),
                ],
              ),
              const Spacer(),
              const Text('Non-scrollable - TabAlignment.fill'),
              TabBar(
                tabAlignment: TabAlignment.fill,
                dividerColor: customColors ? dividerColor : null,
                indicatorColor: customColors ? indicatorColor : null,
                dividerHeight: removeDivider ? 0 : null,
                tabs: const <Widget>[
                  Tab(
                    icon: Icon(Icons.cloud_outlined),
                  ),
                  Tab(
                    icon: Icon(Icons.beach_access_sharp),
                  ),
                  Tab(
                    icon: Icon(Icons.brightness_5_sharp),
                  ),
                ],
              ),
              const Text('Non-scrollable - TabAlignment.center'),
              TabBar(
                tabAlignment: TabAlignment.center,
                dividerColor: customColors ? dividerColor : null,
                indicatorColor: customColors ? indicatorColor : null,
                dividerHeight: removeDivider ? 0 : null,
                tabs: const <Widget>[
                  Tab(
                    icon: Icon(Icons.cloud_outlined),
                  ),
                  Tab(
                    icon: Icon(Icons.beach_access_sharp),
                  ),
                  Tab(
                    icon: Icon(Icons.brightness_5_sharp),
                  ),
                ],
              ),
              const Spacer(),
              const Text('Secondary - TabAlignment.fill'),
              TabBar.secondary(
                tabAlignment: TabAlignment.fill,
                dividerColor: customColors ? dividerColor : null,
                indicatorColor: customColors ? indicatorColor : null,
                dividerHeight: removeDivider ? 0 : null,
                tabs: const <Widget>[
                  Tab(
                    icon: Icon(Icons.cloud_outlined),
                  ),
                  Tab(
                    icon: Icon(Icons.beach_access_sharp),
                  ),
                  Tab(
                    icon: Icon(Icons.brightness_5_sharp),
                  ),
                ],
              ),
              const Text('Secondary - TabAlignment.center'),
              TabBar.secondary(
                tabAlignment: TabAlignment.center,
                dividerColor: customColors ? dividerColor : null,
                indicatorColor: customColors ? indicatorColor : null,
                dividerHeight: removeDivider ? 0 : null,
                tabs: const <Widget>[
                  Tab(
                    icon: Icon(Icons.cloud_outlined),
                  ),
                  Tab(
                    icon: Icon(Icons.beach_access_sharp),
                  ),
                  Tab(
                    icon: Icon(Icons.brightness_5_sharp),
                  ),
                ],
              ),
              const Spacer(),
            ],
          ),
        ),
      ),
    );
  }
}
``` 
	
</details>

### Before

![Screenshot 2023-07-27 at 14 12 36](https://github.com/flutter/flutter/assets/48603081/1c08a9d2-ac15-4d33-8fa1-c765b4b10f92)

### After 

![Screenshot 2023-07-27 at 14 13 12](https://github.com/flutter/flutter/assets/48603081/7e662dfe-9f32-46c9-a128-3024a4782882)

This also contains regression test for https://github.com/flutter/flutter/pull/125974#discussion_r1239089151

```dart
  // This is a regression test for https://github.com/flutter/flutter/pull/125974#discussion_r1239089151.
  testWidgets('Divider can be constrained', (WidgetTester tester) async {
```

![Screenshot 2023-07-27 at 14 16 37](https://github.com/flutter/flutter/assets/48603081/ac2ef49b-2410-46d0-8ae2-d9b77236abba)
2023-08-02 00:48:06 +00:00
Ian Hickson
9c471a9499
ImageProvider.toString uses double.toStringAsFixed (#131348)
This provides consistency for web vs VM (and is more consistent with how we do doubles everywhere else in toStrings).
2023-08-02 00:38:06 +00:00
Polina Cherkasova
35213ceabd
Upgrade Flutter libraries. (#131700) 2023-08-01 12:59:47 -07:00
Dan Field
c57169835a
Avoid concurrent modification of persistent frame callbacks (#131677)
Fixes https://github.com/flutter/flutter/issues/131415

We should do an audit of all such cases though, filed https://github.com/flutter/flutter/issues/131678
2023-08-01 18:38:40 +00:00
Qun Cheng
3cf206ba2c
Update CheckboxListTile and CalendarDatePicker tests for M2/M3 (#131363) 2023-07-31 13:24:48 -07:00
Qun Cheng
71d96ddf9c
Add Expanded/Collapsed State for Semantics (#131233) 2023-07-31 12:09:27 -07:00
Qun Cheng
e0b6b6c451
Reland - "Update Unit Tests for M2/M3" (#131504)
Reverts flutter/flutter#131368
Original PR: https://github.com/flutter/flutter/pull/131292 . The
flutter mirror was out of date and tree was closed, so the original PR
was reverted. Now should be safe to have a reland.
2023-07-31 11:51:27 -07:00
Pierre-Louis
28ee558178
Fix dartdoc for ButtonSegment constructor (#131400)
https://github.com/flutter/flutter/issues/103529
2023-07-31 12:26:11 +00:00
Bruno Leroux
7b6af17f6e
Reland - Fix floating SnackBar throws when FAB is on the top (#131475)
## Description

This PR is a reland of https://github.com/flutter/flutter/pull/129274 with a fix and new test related to the revert (https://github.com/flutter/flutter/pull/131303).

It updates how a floating snack bar is positionned when a `Scaffold` defines a FAB with `Scaffold.floatingActionButtonLocation` sets to one of the top locations.

**Before this PR:**
- When a FAB location is set to the top of the `Scaffold`, a floating `SnackBar` can't be displayed and an assert throws in debug mode.

**After this PR:**
- When a FAB location is set to the top of the `Scaffold`, a floating `SnackBar` will be displayed at the bottom of the screen, above a `NavigationBar` for instance (the top FAB is ignored when computing the floating snack bar position).

![image](https://github.com/flutter/flutter/assets/840911/08fcee6c-b286-4749-ad0b-ba09e653bd94)

## Motivation

This is a edge case related to a discrepancy between the Material spec and the Flutter `Scaffold` customizability:
- Material spec states that a floating `SnackBar` should be displayed above a FAB. But, in Material spec, FABs are expected to be on the bottom.
- Since https://github.com/flutter/flutter/issues/51465, Flutter `Scaffold` makes it valid to show a FAB on the top of the `Scaffold`.

## Related Issue

fixes https://github.com/flutter/flutter/issues/128150

## Tests

Adds 2 tests.
2023-07-28 22:00:20 +00:00
Taha Tesser
48d47ade9d
Update BottomSheet.enableDrag & BottomSheet.showDragHandle docs for animation controller (#131484)
fixes [`AnimationController` must be provided when `BottomSheet.enableDrag` or `BottomSheet.showDragHandle` is true](https://github.com/flutter/flutter/issues/127093)
2023-07-28 19:17:28 +00:00
Qun Cheng
3567140d9e
Deprecate useMaterial3 parameter in ThemeData.copyWith() (#131455) 2023-07-28 10:31:53 -07:00
Taha Tesser
038ec62b28
Add CheckedPopupMenuItem‎.labelTextStyle and update default text style for Material 3 (#131060)
fixes [Update `CheckedPopupMenuItem‎` for Material 3](https://github.com/flutter/flutter/issues/128576)

### Description

- This adds the missing ``CheckedPopupMenuItem‎.labelTextStyle` parameter
- Fixes default text style for `CheckedPopupMenuItem‎`. 
It used `ListTile`'s  `bodyLarge` instead of `LabelLarge` similar to `PopupMenuItem`.

### Code sample

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

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        useMaterial3: true,
        textTheme: const TextTheme(
          labelLarge: TextStyle(
            fontWeight: FontWeight.bold,
            fontStyle: FontStyle.italic,
            letterSpacing: 5.0,
          ),
        ),
      ),
      home: const Example(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Sample'),
        actions: <Widget>[
          PopupMenuButton<String>(
            icon: const Icon(Icons.more_vert),
            itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
              const CheckedPopupMenuItem<String>(
                // labelTextStyle: MaterialStateProperty.resolveWith(
                //     (Set<MaterialState> states) {
                //   if (states.contains(MaterialState.selected)) {
                //     return const TextStyle(
                //       color: Colors.red,
                //       fontStyle: FontStyle.italic,
                //       fontWeight: FontWeight.bold,
                //     );
                //   }

                //   return const TextStyle(
                //     color: Colors.amber,
                //     fontStyle: FontStyle.italic,
                //     fontWeight: FontWeight.bold,
                //   );
                // }),
                child: Text('Mild'),
              ),
              const CheckedPopupMenuItem<String>(
                checked: true,
                // labelTextStyle: MaterialStateProperty.resolveWith(
                //     (Set<MaterialState> states) {
                //   if (states.contains(MaterialState.selected)) {
                //     return const TextStyle(
                //       color: Colors.red,
                //       fontStyle: FontStyle.italic,
                //       fontWeight: FontWeight.bold,
                //     );
                //   }

                //   return const TextStyle(
                //     color: Colors.amber,
                //     fontStyle: FontStyle.italic,
                //     fontWeight: FontWeight.bold,
                //   );
                // }),
                child: Text('Spicy'),
              ),
              const PopupMenuDivider(),
              const PopupMenuItem<String>(
                value: 'Close',
                child: Text('Close'),
              ),
            ],
          )
        ],
      ),
    );
  }
}

``` 
	
</details>

### Customized `textTheme.labelLarge` text theme.
| Before | After |
| --------------- | --------------- |
| <img src="https://github.com/flutter/flutter/assets/48603081/2672438d-b2da-479b-a5d3-d239ef646365" /> | <img src="https://github.com/flutter/flutter/assets/48603081/b9f83719-dede-4c2f-8247-18f74e63eb29"  /> |

### New `CheckedPopupMenuItem‎.labelTextStyle` parameter with material states support
<img src="https://github.com/flutter/flutter/assets/48603081/ef0a88aa-9811-42b1-a3aa-53b90c8d43fb" height="450" />
2023-07-28 17:16:04 +00:00
Daniel Chevalier
f0163c0cd0
Shared state to support multi screen inspection (#129452)
![](https://media.giphy.com/media/KY2dtJNlGPH08w41FN/giphy.gif)

Fixes https://github.com/flutter/devtools/issues/5931

With Multi View applications on the way, we need to be able to manage
the state of multiple Inspector widgets in a consistent way.

Previously each Widget inspector would manage the state of it's own
inspection. This made for a confusing and inconsistent experience when
clicking on the widget inspector of different views.

This PR changes the state management to the WidgetInspectorService
static instance so that all widget inspectors can share that state.

# Demo


https://github.com/flutter/flutter/assets/1386322/70fd18dc-5827-4dcd-8cb7-ef20e6221291
2023-07-28 11:53:26 -04:00
Taha Tesser
058f1660e7
Update Card.color documentation for Material 3 (#131468)
fixes [Card color parameter not respected while using Material 3](https://github.com/flutter/flutter/issues/122177)
2023-07-28 15:28:11 +00:00
Taha Tesser
7d89617a92
Fix TimePicker defaults for hourMinuteTextStyle and dayPeriodTextColor for Material 3 (#131253)
fixes [`TimePicker` color and visual issues](https://github.com/flutter/flutter/issues/127035)

## Description

- fixes default text style for `TimePicker`s  `hourMinuteTextStyle` and added a todo for https://github.com/flutter/flutter/issues/131247
- fixes correct default color not being accessed for  `dayPeriodTextColor`
-  Updates tests

### Code sample

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

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

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

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

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

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Sample'),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            showTimePicker(
              context: context,
              orientation: Orientation.portrait,
              initialEntryMode: TimePickerEntryMode.input,
              initialTime: TimeOfDay.now(),
              builder: (BuildContext context, Widget? child) {
                return MediaQuery(
                  data: MediaQuery.of(context)
                      .copyWith(alwaysUse24HourFormat: true),
                  child: child!,
                );
              },
            );
          },
          child: const Text('Open Time Picker'),
        ),
      ),
    );
  }
}

``` 
	
</details>

### Before

![ezgif com-video-to-gif](https://github.com/flutter/flutter/assets/48603081/b791501f-aed3-44f3-8f75-70a1e28038c6)

### After

![ezgif com-video-to-gif (1)](https://github.com/flutter/flutter/assets/48603081/1bb32064-a9b1-416d-8290-7d22b0d4fdb9)
2023-07-28 14:11:23 +00:00
Jonah Williams
46d074014b
[framework] clean up image provider documentation. (#131416)
Fixes https://github.com/flutter/flutter/issues/130524

loadBuffer was superseded by loadImage
2023-07-27 23:25:04 +00:00
Qun Cheng
16826e062b
Preliminary PR for engine changes for Expanded/Collapsed Submenu button (#131359)
This PR is to skip some unit tests in order to merging an [engine
change](https://github.com/flutter/engine/pull/43983).
2023-07-27 12:23:42 -07:00
Jason Simmons
8a84437989
Manual roll to engine commit 9b14c382 using Dart SDK version 3.2.x (#131371)
Dart SDK 3.2.x requires a new version of the dart_internal package.
2023-07-27 17:33:07 +00:00
Seiya Kokushi
dd9764ec34
Proposal to add barrier configs for showDatePicker, showTimePicker and showAboutDialog. (#131306)
Can configure modal barriers in Flutter's built-in dialogs.
2023-07-27 09:57:27 -07:00
Ian Hickson
48f08e3db2
IgnoreBaseline widget (#131220)
Fixes https://github.com/flutter/flutter/issues/7037
2023-07-27 05:59:17 +00:00
Chris Evans
2240649358
Add 'vm:keep-name' pragmas to platform channel classes (#131271)
Pragma will allow future proofing Dart snapshot utilities to work by preserving the names of important classes used in platform channel communication

@Hixie
2023-07-27 01:30:23 +00:00
Ian Hickson
33e9fd8934
ImageDecoration.lerp (#130533) (#131349)
This primarily implements DecorationImage.lerp().

It also makes some minor tweaks, the main one of which is defering to dart:ui for `clampDouble` instead of duplicating it in package:foundation.

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

This was first landed in https://github.com/flutter/flutter/pull/130533 and reverted in https://github.com/flutter/flutter/pull/131347.
2023-07-26 23:48:08 +00:00
Kate Lovett
bb0c3172f8
Minor adjustments on 2D APIs (#131358)
These tweaks came from https://github.com/flutter/packages/pull/4536

- The TwoDimensionalChildBuilderDelegate asserts that maxXIndex and maxYIndex are null or >= 0
- The TwoDimensionalChildDelegate setter in RenderTwoDimensionalViewport has a covariant to allow type safety for subclasses of RenderTwoDimensionalViewport implementing with other subclasses of TwoDimensionalChildDelegate

I'd like to cherry pick this so https://github.com/flutter/packages/pull/4536 will not have to wait for it to reach stable.
2023-07-26 23:21:05 +00:00
Loïc Sharma
f359d9e27a
Revert "Update Unit Tests for M2/M3" (#131368)
Reverts flutter/flutter#131292

This PR is affected by https://g-issues.skia.org/issues/40045533.

See @Piinks's [explanation](https://discord.com/channels/608014603317936148/613398423093116959/1133885989358678076):

> The mirror is probably out of sync. The failing commit introduced new changes, but they have not been updated yet. I would revert the PR until we can check the mirror. Last week it went 2+ hours out of sync so rerunning it may not green the tree for a while.
2023-07-26 22:46:20 +00:00
Qun Cheng
5d76d1a561
Update Unit Tests for M2/M3 (#131292)
Updated golden tests in 

* ink_sparkle_test.dart
* material_test.dart
* page_test.dart
* progress_indicator_test.dart

to have M2 and M3 versions.

More info in #127064
2023-07-26 21:24:29 +00:00
Ian Hickson
27e912316f
Revert "ImageDecoration.lerp" (#131347)
Reverts flutter/flutter#130533

Tree breakage.
2023-07-26 11:09:59 -07:00
Ian Hickson
bae1ac2f6f
ImageDecoration.lerp (#130533)
This primarily implements DecorationImage.lerp().

It also makes some minor tweaks, the main one of which is defering to dart:ui for `clampDouble` instead of duplicating it in package:foundation.

Fixes https://github.com/flutter/flutter/issues/12452
2023-07-26 17:31:23 +00:00
Ian Hickson
552700999d
Document the Flow/Opacity/hit-test issues (#131239)
Closes https://github.com/flutter/flutter/issues/6100.
2023-07-26 17:31:21 +00:00
Xilai Zhang
9bd87ec984
[flutter roll] Revert "Fix floating SnackBar throws when FAB is on the top" (#131303)
Reverts flutter/flutter#129274

temporarily putting up a revert in case a fix is difficult
context: [b/293202068](http://b/293202068) youtube integration tests failed
2023-07-26 13:31:29 +00:00
Caffeinix
a4f7906692
Reorders menu item button shortcuts on Mac-like platforms (#129309)
The Apple Human Interface Guidelines give a specific ordering of the symbols
used as modifier keys in menu shortcuts.  These guidelines are encoded into
the native Cocoa or UIKit menu classes, and are intended to ensure that symbols
are always aligned into columns of like symbols and do not move around in the
case of dynamic menu items (for example, holding Option will transform certain
menu items into different versions that take the Option key, so the Option key
symbol appears to the left of most other symbols to avoid reordering).

The Material spec says to use symbols for modifier keys on Mac and iOS, as this
is what users there are familiar with.  It stands to reason that we should
follow the platform guidelines fully, so this changes the MenuItemButton class
to honor the HIG-compliant symbol ordering on Mac and iOS.

Fixed: #129308
2023-07-26 03:07:27 +00:00
Dan Field
efa69ba95b
Add example for locking screen orientation in a letterboxing environment (#131266)
Android may choose to letterbox applications that lock orientation. This gets particularly bad on foldable devices, where a developer may want to lock orientation when the devices is folded and unlock when unfolded. However, if the app is letterboxed when unfolded, the `MediaQuery.of(context).size` will never report the full display size, only the letterboxed window size. This may result in an application getting "stuck" in portrait mode.

/cc @TytaniumDev
2023-07-25 23:07:51 +00:00
Bruno Leroux
eb4891226e
Update BottomAppBar and BottomAppBarTheme tests for M3 (#130983)
This PR updates `BottomAppBar` and `BottomAppBarTheme` tests for M3 migration.

More info in https://github.com/flutter/flutter/issues/127064

- Some tests are M2 or M3 only.
- Added several M3 tests.
- One golden change.
2023-07-25 22:56:49 +00:00
Alex Li
9f374f12ea
🚀 Expose scrollControlDisabledMaxHeightRatio to the modal bottom sheet (#129688)
Adding the `scrollControlDisabledMaxHeightRatio` parameter for modal bottom sheet widgets, and using the default value `9.0 / 16.0` to avoid breaking.

Resolves #129690.
2023-07-25 18:24:43 +00:00
Loïc Sharma
300c5d8285
Revert "Proposal to add barrier configs for showDatePicker, showTimePicker and showAboutDialog." (#131278)
Reverts flutter/flutter#130484. /cc @ronnnnn

Example failure: https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20framework_tests_libraries/12185/overview

<details>
<summary>Failure logs...</summary>

```
04:51 +5379 ~18: /Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart: Barrier dismissible Barrier is dismissible with default parameter                                    
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: <1>
  Actual: <2>

When the exception was thrown, this was the stack:
#4      main.<anonymous closure>.<anonymous closure> (file:///Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart:776:7)
<asynchronous suspension>
#5      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:165:15)
<asynchronous suspension>
#6      TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1008:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

This was caught by the test expectation on the following line:
  file:///Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart line 776
The test description was:
  Barrier is dismissible with default parameter
════════════════════════════════════════════════════════════════════════════════════════════════════

04:51 +5379 ~18 -1: /Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart: Barrier dismissible Barrier is dismissible with default parameter [E]                             
  Test failed. See exception logs above.
  The test description was: Barrier is dismissible with default parameter
  
To run this test again: /Volumes/Work/s/w/ir/x/w/flutter/bin/cache/dart-sdk/bin/dart test /Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart -p vm --plain-name 'Barrier dismissible Barrier is dismissible with default parameter'
```

</details>
2023-07-25 18:20:31 +00:00
Taha Tesser
62adfcf737
Fix RawChip doesn't use ChipTheme.showCheckmark value (#131257)
fixes [`RawChip` doesn't use `ChipThemeData.showCheckmark` value](https://github.com/flutter/flutter/issues/119163)

### Description

`RawChip.showCheckmark` is nullable yet the constructor falsely assigns a default which breaks `ChipTheme` support. This PR removes the falsely assigned default value.

### Code sample

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

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

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

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

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

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Sample'),
      ),
      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
            const RawChip(
              selected: true,
              label: Text('RawChip'),
            ),
            FilterChip(
              selected: true,
              label: const Text('RawChip'), onSelected: (bool value) {  },
            ),
          ],
        ),
      ),
    );
  }
}

``` 
	
</details>

### Before
![before](https://github.com/flutter/flutter/assets/48603081/c8050c28-d988-4c72-8e0a-6455aa02d119)

### After

![after](https://github.com/flutter/flutter/assets/48603081/d5e83e81-6c12-4594-a2fd-8f113d6c9b54)
2023-07-25 15:37:17 +00:00
Seiya Kokushi
9def8f6bc5
Proposal to add barrier configs for showDatePicker, showTimePicker and showAboutDialog. (#130484)
### Overview

Add `barrierDismissible`, `barrierColor` and `barrierLabel` parameters to  `showDatePicker`, `showTimePicker` and `showAboutDialog` which calls `showDialog` internally.
We can change these parameters with `showDialog` and Dialog widgets (like `DatePickerDialog`, `TimePickerDialog` or `AboutDialog`) directly. But, I think it is prefer to provide interfaces same as `showDialog` to keep application wide unified looks if it is used internally.

Fixes #130971
2023-07-25 15:32:20 +00:00
Ian Hickson
8a01c9b707
Use toStringAsFixed in DecorationImage.toString (#131026)
This makes the output less sensitive on JS int vs double shenanigans.
2023-07-24 19:59:06 +00:00
Taha Tesser
5554b0eeb3
Fix M3 TimePicker dial background uses incorrect color (#131045)
fixes [Material3: TimePicker clock dial use wrong spec color and its web spec has a mistake](https://github.com/flutter/flutter/issues/118657)

### Description 

This PR fixes the default color used for the Material 3 dial background.

### 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 ThemeData theme = ThemeData(useMaterial3: true);

    return MaterialApp(
      debugShowCheckedModeBanner: false,
      // theme: theme,
      theme: theme.copyWith(
        colorScheme: theme.colorScheme.copyWith(
          surfaceVariant: const Color(0xffffbf00),
        ),
      ),
      home: const Example(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Sample'),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            showTimePicker(
              context: context,
              initialTime: TimeOfDay.now(),
            );
          },
          child: const Text('Open Time Picker'),
        ),
      ),
    );
  }
}
``` 
	
</details>

### Default dial background color 
| Before | After |
| --------------- | --------------- |
| <img src="https://github.com/flutter/flutter/assets/48603081/59514586-60c6-489f-b024-f659a26fa1e7"  /> | <img src="https://github.com/flutter/flutter/assets/48603081/75c3c360-df2b-47c8-8187-136ff6d963b6"  /> |

### Custom color scheme
| Before | After |
| --------------- | --------------- |
| <img src="https://github.com/flutter/flutter/assets/48603081/666dd2fc-7ee2-4268-9af0-923019adfccd"  /> | <img src="https://github.com/flutter/flutter/assets/48603081/f32dc39e-a43f-4a63-a6e4-9df479b723ed"  /> |
2023-07-24 18:30:23 +00:00
Bruno Leroux
97e0a0589e
Fix floating SnackBar throws when FAB is on the top (#129274)
## Description

This PR updates how a floating snack bar is positionned when a `Scaffold` defines a FAB with `Scaffold.floatingActionButtonLocation` sets to one of the top locations.

**Before this PR:**
- When a FAB location is set to the top of the `Scaffold`, a floating `SnackBar` can't be displayed and an assert throws in debug mode.

**After this PR:**
- When a FAB location is set to the top of the `Scaffold`, a floating `SnackBar` will be displayed at the bottom of the screen, above a `NavigationBar` for instance (the top FAB is ignored when computing the floating snack bar position).

![image](https://github.com/flutter/flutter/assets/840911/08fcee6c-b286-4749-ad0b-ba09e653bd94)

## Motivation

This is a edge case related to a discrepancy between the Material spec and the Flutter `Scaffold` customizability:
- Material spec states that a floating `SnackBar` should be displayed above a FAB. But, in Material spec, FABs are expected to be on the bottom.
- Since https://github.com/flutter/flutter/issues/51465, Flutter `Scaffold` makes it valid to show a FAB on the top of the `Scaffold`.

## Related Issue

fixes https://github.com/flutter/flutter/issues/128150

## Tests

Adds 1 test.
2023-07-24 18:25:04 +00:00
Michael Goderbauer
283437a2d2
Update link to unbounded constraints error (#131205)
Fixes https://github.com/flutter/flutter/issues/130805.
2023-07-24 18:23:49 +00:00
Tae Hyung Kim
8a37b8ba35
Optimize SliverMainAxisGroup/SliverCrossAxisGroup paint function (#129310)
This PR changes the paint functions for SliverMainAxisGroup and SliverCrossAxisGroup so that only visible slivers are painted.

Fixes https://github.com/flutter/flutter/issues/129214.
2023-07-24 18:19:03 +00:00
Sabin Neupane
c65cab8fa3
[DropdownMenu] Close menu after editing is complete (#130710)
Fixes: #130674 

Before: The dropdown menu was not closed if empty text was provided

After: The dropdown menu is closed even if empty text is provided

https://github.com/flutter/flutter/assets/61322712/fccac501-9fca-4f60-8a94-abfc50552ec9

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
2023-07-24 18:15:53 +00:00
Lexycon
2a1f26c4e1
Fix material date picker behavior when changing year (#130486)
This PR changes the material date picker behavior when changing the year so that it matches the native picker and the material component guideline. (#81547)

See material component guideline for the date picker: [Material component date-picker behavior](https://m3.material.io/components/date-pickers/guidelines#1531a81f-4052-4a75-a20d-228c7e110156)
See also: [Material components android discussion](https://github.com/material-components/material-components-android/issues/1723)

When selecting another year in the native picker, the same day will be selected (by respecting the boundaries of the date picker). The current material date picker does not select any day when changing the year. This will lead to confusion if the user presses OK and the year does not get updated.

So here is my suggestion:
It will try to preselect the day like the native picker:
 - respecting the boundaries of the date picker (firstDate, lastDate)
 - changing from leapyear 29th february will set 28th february if not a leapyear is selected
 - only set the day if it is selectable (selectableDayPredicate)

The calendar shown in the recording was setup with this parameters:
```
firstDate: DateTime(2016, DateTime.june, 9),
initialDate: DateTime(2018, DateTime.may, 4),
lastDate: DateTime(2021, DateTime.january, 15),
```
 
https://github.com/flutter/flutter/assets/13588771/3041c296-b9d0-4078-88cd-d1135fc343b3

Fixes #81547
2023-07-24 16:03:05 +00:00
Martin Kustermann
9c10151508
Use utf8.encode() instead of longer const Utf8Encoder.convert() (#130567)
The change in [0] has propagated now everywhere, so we can use
`utf8.encode()` instead of the longer `const Utf8Encoder.convert()`.

Also it cleans up code like

```
  TypedData bytes;
  bytes.buffer.asByteData();
```

as that is not guaranteed to be correct, the correct version would be

```
  TypedData bytes;
  bytes.buffer.asByteData(bytes.offsetInBytes, bytes.lengthInBytes);
```

a shorter hand for that is:

```
  TypedData bytes;
  ByteData.sublistView(bytes);
```

[0] https://github.com/dart-lang/sdk/issues/52801
2023-07-24 11:26:05 +02:00