8269 Commits

Author SHA1 Message Date
Nate Biggs
30cce4dcd2
Update fake_codec.dart to use Future.value instead of SynchronousFuture (#152182)
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.
2024-07-25 01:23:05 +00:00
Tong Mu
748afd9775
[CupertinoAlertDialog] Rewrite (#150410)
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.
2024-07-24 23:18:02 +00:00
Victor Sanni
373efb0764
Revert "Make CupertinoRadio's mouseCursor a WidgetStateProperty" (#152254)
Reverts flutter/flutter#151910, awaiting further discussion on `WidgetStateProperty`.
2024-07-24 22:47:55 +00:00
Renzo Olivares
00eeabf584
Fix: A selectable's selection under the active selection should not be cleared on right-click (#151851)
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.
2024-07-24 22:46:22 +00:00
Byeongjin Kang
6fdcb0a511
feat: Add alignmentOffset to DropdownMenu (#151731)
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.
2024-07-24 21:17:06 +00:00
chunhtai
7912e6d27e
Updates mark needs semantics update logic for overlay portal (#151688)
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.
2024-07-24 00:30:19 +00:00
davidhicks980
f9dc7526fd
[widgets/shortcuts] Add includeSemantics property to the Shortcuts widget. (#152077)
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
2024-07-23 15:46:08 +00:00
Justin McCandless
bb8f6b04d5
Will pop scope on home route (#152057)
Fixes a bug where WillPopScope no longer worked on the home route.

With this PR, Android's predictive back feature will be explicitly disabled when a WillPopScope widget is in the widget tree. To get the same behavior and still support predictive back, use PopScope.
2024-07-22 10:06:55 -07:00
Polina Cherkasova
c9ee9ad616
Clean up leaky test. (#152094) 2024-07-22 09:53:40 -07:00
Victor Sanni
5ef969a24f
Make CupertinoRadio's mouseCursor a WidgetStateProperty (#151910)
https://github.com/flutter/flutter/pull/149681 introduced `mouseCursor `to `CupertinoRadio` as a `MouseCursor` instead of a `WidgetStateProperty` to match Material Radio's `mouseCursor` property for `.adaptive`.

This PR changes `mouseCursor` to be of type `WidgetStateProperty<MouseCursor>` as per review comments in https://github.com/flutter/flutter/pull/151788#discussion_r1680538286.

PR bringing `mouseCursor` into `CupertinoRadio`: https://github.com/flutter/flutter/pull/149681.

Part of https://github.com/flutter/flutter/issues/58192
2024-07-19 21:01:10 +00:00
Renzo Olivares
93fd29455d
Fix SelectionArea scrolling conflicts (#151138)
Fixes #150897
2024-07-18 21:50:20 +00:00
Renzo Olivares
6e877226bf
Fix: BaseTapAndDragGestureRecognizer should reset drag state after losing gesture arena (#151989)
This PR properly resets the drag state when losing the gesture arena or when the recognizer stops tracking the current pointer. The _dragState enum was reset properly, but I had forgotten to also reset the `_start`, this caused an issue when the recognizer won the gesture arena the next time, as it tries to detect a drag given the old `_start` in `acceptGesture`, but the `_dragState` has been reset causing an assertion to trigger.
2024-07-18 21:01:25 +00:00
Nate Wilson
db80f4e713
WidgetState mapping (#146043)
This pull request implements [enhanced enum](https://dart.dev/language/enums#declaring-enhanced-enums) features for the new `WidgetState` enum, in order to improve the developer experience when creating and using `WidgetStateProperty` objects.

`WidgetState` now has a `.matchesSet()` method:

```dart
// identical to "states.contains(WidgetState.error)"
final bool hasError = WidgetState.error.isSatisfiedBy(states);
```

This addition allows for wide variety of `WidgetStateProperty` objects to be constructed in a simple manner.

<br><br>

```dart
// before
final style = MaterialStateTextStyle.resolveWith((states) {
  if (states.contains(MaterialState.error)) {
    return TextStyle(color: Colors.red);
  } else if (states.contains(MaterialState.focused)) {
    return TextStyle(color: Colors.blue);
  }
  return TextStyle(color: Colors.black);
});

// after
final style = WidgetStateTextStyle.fromMap({
  WidgetState.error:   TextStyle(color: Colors.red),
  WidgetState.focused: TextStyle(color: Colors.blue),
  WidgetState.any:     TextStyle(color: Colors.black), // "any" is a static const member, not an enum value
});
```

```dart
// before
final color = MaterialStateProperty.resolveWith((states) {
  if (states.contains(MaterialState.focused)) {
    return Colors.blue;
  } else if (!states.contains(MaterialState.disabled)) {
    return Colors.black;
  }
  return null;
});

// after
final color = WidgetStateProperty<Color?>.fromMap({
  WidgetState.focused:   Colors.blue,
  ~WidgetState.disabled: Colors.black,
});
```

```dart
// before
const activeStates = [MaterialState.selected, MaterialState.focused, MaterialState.scrolledUnder];

final color = MaterialStateColor.resolveWith((states) {
  if (activeStates.any(states.contains)) {
    if (states.contains(MaterialState.hovered) {
      return Colors.blueAccent;
    }
    return Colors.blue;
  }
  return Colors.black;
});

// after
final active = WidgetState.selected | WidgetState.focused | WidgetState.scrolledUnder;

final color = WidgetStateColor.fromMap({
  active & WidgetState.hovered: Colors.blueAccent,
  active:  Colors.blue,
  ~active: Colors.black,
});
```

<br>

(fixes #146042, and also fixes #143488)
2024-07-18 16:48:06 +00:00
Bruno Leroux
3acb13b911
Reland fix InputDecorator hint default text style on M3 (#150835)
## Description

This PR is a partial reland of https://github.com/flutter/flutter/pull/148944 which was reverted in https://github.com/flutter/flutter/pull/149448.
It makes the `InputDecoration.hintText` font style compliant with the M3 spec.

(First part of the reland was merged in https://github.com/flutter/flutter/pull/150278)

## Related Issue

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

## Tests

Updates several tests.
2024-07-17 21:48:29 +00:00
Victor Sanni
4d9c1682e4
Constrain CupertinoContextMenu animation to safe area (#151860)
## Before

https://github.com/user-attachments/assets/84b86117-3820-4ac6-a204-81b123e5e543

## After

https://github.com/user-attachments/assets/f3374e69-ea7a-4bbf-9c92-669d0520c922

Fixes https://github.com/flutter/flutter/issues/122951.
2024-07-17 21:28:06 +00:00
Qun Cheng
844eb2fe76
Create CarouselView widget - Part 2 (#149775)
This PR is to create `Carousel.weighted` so the size of each carousel item is based on a list of weights. While scrolling, item sizes are changing dynamically based on the scrolling progress.

https://github.com/flutter/flutter/assets/36861262/181472b0-6f8b-48e7-b191-ab5f7c88c0c8
2024-07-17 19:56:01 +00:00
flyboy
0a1d550e5f
Add ListTileControlAffinity to ListTileTheme (#150695)
fixes https://github.com/flutter/flutter/issues/146414

--- 

I saw @abikko submitted a PR https://github.com/flutter/flutter/pull/146630, but it was not completed due to CLA and lack of test cases.
I am willing to complete this PR in combination with @abikko's code (I don't know if this is allowed) 

 This PR adds contorlAffinity to ListTileTheme so that [CheckboxListTile], [RadioListTile], [SwitchListTile], and [ExpansionTile] can read and use it 

 For example: If ListTileTheme in Theme sets contorlAffinity, then [CheckboxListTile] can directly use contorlAffinity in ListTileTheme. Of course, if contorlAffinity is also set in [CheckboxListTile], the property in [CheckboxListTile] will be used first.
2024-07-17 14:06:13 +00:00
Sam Rawlins
e497ed7db0
Remove unnecessary parens in test (#151846)
In order to address [a bug in `unnecessary_parenthesis`](https://github.com/dart-lang/linter/issues/3046), we are reporting a few more cases in `unnecessary_parenthesis`. `a = (b = c)` is one such case. This change is being made in https://dart-review.googlesource.com/c/sdk/+/366891.
2024-07-17 09:54:34 +00:00
Tong Mu
de04c13fdb
[CupertinoActionSheet] Support legacy buttons (#151136)
Fixes https://github.com/flutter/flutter/issues/150980

This PR allows buttons implemented with `GestureDetector.onTap` to be selected in the action sheet.
2024-07-17 05:09:24 +00:00
Tong Mu
f50feec5be
[CupertinoActionSheet] Add haptic feedback (#151420)
This PR implements the behavior of native action sheets that produces haptic feedback when the user slides into a button.
2024-07-17 04:57:26 +00:00
John Stef
aed548992a
Add borderRadius property to PopupMenuButton (#151228)
This PR is adding borderRadius property to PopupMenuButton. PopupMenuButton has a child wrapped in an InkWell widget where as of right now you can't customize it's border radius resulting in wrong splash effect when the child has border radius.

Fixes: #151227 

https://github.com/flutter/flutter/assets/20647774/93feb0a4-c4ff-4059-bde2-e59c4d35e2b6
2024-07-16 20:27:11 +00:00
Taha Tesser
e1cd7b11f6
Introduce Switch.padding (#149884)
fixes [Switch has some padding that leads to uncentered UI](https://github.com/flutter/flutter/issues/148498)

### 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,
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              ColoredBox(
                color: Colors.amber,
                child: Switch(
                  padding: EdgeInsets.zero,
                  value: true,
                  materialTapTargetSize: MaterialTapTargetSize.padded,
                  onChanged: (bool value) {},
                ),
              ),
              const SizedBox(height: 16),
              ColoredBox(
                color: Colors.amber,
                child: Switch(
                  value: true,
                  materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                  onChanged: (bool value) {},
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
```

</details>

### Default Switch size

<img width="476" alt="Screenshot 2024-07-11 at 13 25 05" src="https://github.com/flutter/flutter/assets/48603081/f9f3f6c6-443d-4bd5-81d4-5e314554b032">

### Update Switch size using the new `Switch.padding` to address  [Switch has some padding that leads to uncentered UI](https://github.com/flutter/flutter/issues/148498)

<img width="476" alt="Screenshot 2024-07-11 at 13 24 40" src="https://github.com/flutter/flutter/assets/48603081/aea0717b-e852-4b8d-b703-c8c4999d4863">
2024-07-16 20:25:09 +00:00
Victor Sanni
b9e4416ad3
Add semanticLabel to CupertinoCheckbox (#151789) 2024-07-16 17:47:18 +00:00
arbaker2
30bf2888b9
Add support for inverting CircularNotchedRectangle to optionally be drawn on the bottom of a path (#151386)
This PR allows for an optional argument [inverted[ to be passed to the [getOuterPath] method of a CircularNotchedRectangle object in order to invert the notch for situations where it is desired to draw the notch on the bottom of the path. This allows both of the below paths in the below screenshot to be drawn and changes no default behavior. 

![Simulator Screenshot - iPhone 15 - 2024-07-07 at 11 46 12](https://github.com/flutter/flutter/assets/71237742/57c1370d-19dd-4f65-aa85-f15723a4843b)

*List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.*
This add a feature similar to the one discussed in #49973, original feature proposal #151381

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
2024-07-15 22:08:21 +00:00
Taha Tesser
9e88446f89
Fix Slider thumb doesn't align with divisions, thumb padding, and rounded corners (#149594)
fixes [[Slider] Thumb's center doesn't align with division's center](https://github.com/flutter/flutter/issues/62567)
fixes [Slider thumb doesn't respect round slider track shape](https://github.com/flutter/flutter/issues/149591)
fixes [`RoundedRectSliderTrackShape` corners are not rendered correctly](https://github.com/flutter/flutter/issues/149589)

(Verified these behaviors with Android components implementation)

### 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> {
  double _value = 5.0;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        sliderTheme: const SliderThemeData(
          trackHeight: 32,
          thumbColor: Colors.green,
          activeTrackColor: Colors.deepPurple,
          inactiveTrackColor: Colors.amber,
        ),
      ),
      home: Scaffold(
        body: Slider(
          value: _value,
          // divisions: 10,
          // ignore: avoid_redundant_argument_values
          min: 0,
          max: 10,
          onChanged: (double value) {
            setState(() {
              _value = value;
            });
          },
        ),
      ),
    );
  }
}
```

</details>

### Description
This PR fixes several core `Sliders` issues which are apparent in https://github.com/flutter/flutter/pull/147783. As a result, fixing the these bugs will unblock it.

### 1. Fixes the thumb doesn't align with `Slider` divisions.

![Group 8](https://github.com/flutter/flutter/assets/48603081/9aa138ae-9525-4af4-8fc7-3cea0692a6d7)

![Group 9](https://github.com/flutter/flutter/assets/48603081/e97940ae-a1c8-4b8b-9971-1cf417d32e40)

### 2.  Fixes `RoundedRectSliderTrackShape` corners are not rendered correctly.

![Group 10](https://github.com/flutter/flutter/assets/48603081/ed20a6bb-d5c9-486b-a020-2c9ca7de55da)

### 3.  Fixes round track shape corners when the thumb is at the start or end of the round track shape.

![Group 4](https://github.com/flutter/flutter/assets/48603081/37a2e820-402d-4964-a206-717ccf1c5c02)

![Group 3](https://github.com/flutter/flutter/assets/48603081/5d36d523-5fb7-466f-9d53-b6928963fcab)

![Group 7](https://github.com/flutter/flutter/assets/48603081/8f3b4c48-f04d-4681-a62f-a7ea5a3e19fa)
2024-07-15 07:09:09 +00:00
Bruno Leroux
bf6c455d4a
Update obsolete comment in InputDecorator test (#151651)
Update one comment which is obsolete since https://github.com/flutter/flutter/pull/146754
2024-07-12 13:23:03 +00:00
Taha Tesser
de2dbf4eae
Fix TabBar tab indicator stretch effect (#150868)
fixes [[Material3] TabBar indicator stretch effect behaving weirdly with long tabs](https://github.com/flutter/flutter/issues/149662)

This PR fixes the tab indicator stretch effect, it currently stretches from both sides.  After the fix, tab indicator stretches depending on next size of the indicator and direction of the scroll.

The fix is based on Android Components implementation of the elastic/stretch effect.

20f92dfb51/lib/java/com/google/android/material/tabs/ElasticTabIndicatorInterpolator.java (L46-L78)

### Code sample

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

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: ScrollConfiguration(
        behavior: ScrollConfiguration.of(context)
            .copyWith(dragDevices: <PointerDeviceKind>{
          PointerDeviceKind.touch,
          PointerDeviceKind.mouse,
        }),
        child: DefaultTabController(
          length: 8,
          child: Scaffold(
            appBar: AppBar(
              bottom: const TabBar(
                isScrollable: true,
                tabAlignment: TabAlignment.start,
                tabs: <Widget>[
                  Tab(text: 'Home'),
                  Tab(text: 'Search'),
                  Tab(text: 'Add'),
                  Tab(text: 'Favorite'),
                  Tab(text: 'The longest text...'),
                  Tab(text: 'Short'),
                  Tab(text: 'Longer text...'),
                  Tab(text: 'Profile'),
                ],
              ),
            ),
            body: const TabBarView(
              children: <Widget>[
                Center(child: Text('Page')),
                Center(child: Text('Page')),
                Center(child: Text('Page')),
                Center(child: Text('Page')),
                Center(child: Text('Page')),
                Center(child: Text('Page')),
                Center(child: Text('Page')),
                Center(child: Text('Page')),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
```

</details>

### Before

https://github.com/flutter/flutter/assets/48603081/618d0ba9-40a5-458f-9fdc-5330505a6711

### After

https://github.com/flutter/flutter/assets/48603081/b7fa851e-e7a6-4b66-b77d-f88c7f4381da
2024-07-12 09:37:29 +00:00
Victor Sanni
dddea4d155
Roll Switch.adaptive changes into CupertinoSwitch (#149465)
Brings over the changes from `Switch.adaptive` into `CupertinoSwitch`.

This change adds the following `Switch` parameters to `CupertinoSwitch`:
`inactiveThumbColor,` `activeThumbImage`, `onActiveThumbImageError`, `inactiveThumbImage`, `onInactiveThumbImageError`, `trackOutlineColor`, `trackOutlineWidth`, `thumbIcon`, `mouseCursor`. 

The following `Switch` parameters are ignored:

* `activeTrackColor`: because `activeColor` has the same function.
* `inactiveTrackColor`: because `trackColor` has the same function.
* `materialTapTargetSize`: because it is only applicable in `Material`.
* `hoverColor`, `overlayColor`, `splashRadius`: because these parameters configure the radial reaction overlay in `Material`, so are not applicable here.

The following `CupertinoSwitch` parameters which are absent from `Switch.adaptive` are retained:

* `onLabelColor`, 
* `offLabelColor`, 
* `applyTheme`

`trackColor` and `thumbColor` are of type `WidgetStateProperty` in Material `Switch`, but are currently of type `Color` in `CupertinoSwitch`. For backwards compatibility, both parameters are kept as `Color`s, but can be resolved in different `WidgetState`s using `WidgetStateColor.resolve()`.

This PR does not apply any fidelity updates to `CupertinoSwitch`.

Part of https://github.com/flutter/flutter/issues/149275

Related PRs: https://github.com/flutter/flutter/pull/130425 https://github.com/flutter/flutter/pull/148804
2024-07-12 00:16:10 +00:00
Michael Goderbauer
fb290b3121
docimports for flutter_goldens, flutter_localizations, flutter_web_plugins, fuchsia_remote_debug_protocol, integration_test (#151271)
Part of https://github.com/flutter/flutter/issues/150800
2024-07-11 20:15:05 +00:00
Bui Anh Viet
bc3d2feb9c
Fix: Submenu anchor misaligned with child panel in web (Resolved #151081) (#151294)
Fix: Submenu anchor misaligned with child panel in web (Resolved #151081)

- The issue comes from different in calculating the position of the menu in web and mobile.
- The calculation is currently base on function `getPositionForChild()` inside `_MenuLayout` in `menu_anchor.dart`, which base on the `anchorRect`
- The calculation of `anchorRect` is from `upperLeft` and `bottomRight`
- `upperLeft` is result of `localToGlobal()` function, which take the `point` arguments to be the base line. Right now, `point` is refer to `Offset.zero`, but it should not be Offset.zero since we having `densityAdjustment`, which is different between web and mobile
- Change `point` from `Offset.zero` to `Offset(dx, -dy)` should fix the error. Use `dx` instead of `-dx` since `dx` already be recalculated refer to the above comment on `densityAdjustment`.
Before:
![Screenshot 2024-07-03 at 10 28 51](https://github.com/flutter/flutter/assets/57765714/cd634ce5-8699-49ee-806f-435cbbca81a4)
After:
![Screenshot 2024-07-03 at 10 28 21](https://github.com/flutter/flutter/assets/57765714/81119996-b3e5-4e45-b44b-11fff8521998)

Issue: https://github.com/flutter/flutter/issues/151081
2024-07-11 19:25:18 +00:00
Jefferey Neuffer
90025e2964
expose keyboardType in DropdownMenu #150894 (#150896)
This PR exposes the `keyboardType` parameter in DropdownMenu, allowing the type of keyboard to be used for the text input to be changed.

fixes #150894
2024-07-11 18:30:57 +00:00
derdilla
defdb958ff
Add TimeOfDay comparison methods (#151233)
Implement Comparable for the TimeOfDay class as discussed in #139098. 

Also implements utility methods as `isBefore`, `isAfter` and `isAtSameTimeAs` for convenience and parity with `DateTime` from the dart sdk.
2024-07-11 16:51:35 +00:00
Michael Goderbauer
a1bd8434b5
doc imports for enum values (#151548)
To verify that a9e6fefa91 works.

Part of https://github.com/flutter/flutter/issues/150800.
2024-07-10 21:39:20 +00:00
Tong Mu
b185d0fcf7
[CupertinoActionSheet] Fix padding and font size of buttons (#151199)
This PR updates the padding and font size of `CupertinoActionSheet`'s buttons to match native.

The rules are derived from measuring on simulators:
- The vertical padding is proportional to font size.
- The horizontal padding is fixed.
- The font size vary with text scaling in a way that doesn't exactly fit into any category within the HIG specification. This PR uses a segmented curve with interpolation to roughly match this non-linear curve. 

### Comparison 

(Left to right: Native, Flutter after PR, Flutter before PR. The number at the bottom is the system text scale level, from 1 being extra small to 12 being accessibility large 5.)

<img width="1019" alt="image" src="https://github.com/flutter/flutter/assets/1596656/65c2f222-1d6d-4485-b5f7-7d0a0c0ad56a">

<img width="1141" alt="image" src="https://github.com/flutter/flutter/assets/1596656/bc44e930-4cc8-4af4-944b-3056bb47de69">

<img width="1075" alt="image" src="https://github.com/flutter/flutter/assets/1596656/84659081-d518-494d-8b9c-a83fe23b8ffd">
2024-07-10 21:08:02 +00:00
Yegor
fe07fb4eba
fix heading level absorption, diagnostics; add tests and an a11y use-case (#151421)
Multiple fixes related to heading levels:

* Fix heading level absorption. Heading level would get erased when a semantics config is absorbed into another. With this change the highest heading level wins.
* Add `headingLevel` to the diagnostics of `SemanticsNode`.
* Add unit-tests for heading levels.
* Add an a11y use-case for headings.

Improves https://github.com/flutter/flutter/issues/46789 and general accessibility of headings.
2024-07-10 05:11:38 +00:00
Polina Cherkasova
745d2b4d2a
Clean up leaky test. (#151131) 2024-07-09 15:54:17 -07:00
Taha Tesser
850d76db74
Fix Material 3 Dialog default background color (#151400)
fixes [[Material 3] Wrong `Dialog` background color from ColorScheme](https://github.com/flutter/flutter/issues/148849
)

### Code sample

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

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

/// Flutter code sample for [showDialog].

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: const DialogExample(),
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.green,
          surfaceContainerHigh: Colors.amber,
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('showDialog Sample')),
      body: Center(
        child: OutlinedButton(
          onPressed: () => _dialogBuilder(context),
          child: const Text('Open Dialog'),
        ),
      ),
    );
  }

  Future<void> _dialogBuilder(BuildContext context) {
    return showDialog<void>(
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: const Text('Basic dialog title'),
          content: const Text(
            'A dialog is a type of modal window that\n'
            'appears in front of app content to\n'
            'provide critical information, or prompt\n'
            'for a decision to be made.',
          ),
          actions: <Widget>[
            TextButton(
              style: TextButton.styleFrom(
                textStyle: Theme.of(context).textTheme.labelLarge,
              ),
              child: const Text('Disable'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
            TextButton(
              style: TextButton.styleFrom(
                textStyle: Theme.of(context).textTheme.labelLarge,
              ),
              child: const Text('Enable'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    );
  }
}
```

</details>

### Before

<img width="674" alt="Screenshot 2024-07-08 at 14 26 39" src="https://github.com/flutter/flutter/assets/48603081/a95160f5-947e-4a6e-a3a5-82c94980c744">

### After

<img width="674" alt="Screenshot 2024-07-08 at 14 26 28" src="https://github.com/flutter/flutter/assets/48603081/fa912519-2a79-4fd5-a695-6e18542f0005">
2024-07-09 19:55:47 +00:00
PurplePolyhedron
f194cd3298
Make FittedBox not throw when child has zero size. (#150430)
fix https://github.com/flutter/flutter/issues/135082 , fix https://github.com/flutter/flutter/issues/139539 , fix https://github.com/flutter/flutter/issues/142910

Before, `FittedBox` would throw when child size is zero, unless the constraint is tight and fit is not `BoxFit.scaleDown`.
2024-07-08 22:51:04 +00:00
Greg Spencer
c082abe629
Re-enable SemanticsAction.focus matchers (#150990)
## Description

This re-enables the `SemanticsAction.focus` matchers so that they actually do something now instead of ignoring the action.

This was so that we could land the focus action changes without causing breakages in customer tests, and now that customer tests have been updated, we can land this PR turning it on again.

## Related Issues
 - Fixes https://github.com/flutter/flutter/issues/149842

## Related PRs
 - https://github.com/flutter/flutter/pull/149840

## Tests
 - Updates semantics tests to actually look for the focus action.
2024-07-08 21:01:56 +00:00
Hans Muller
f2be1260df
Added SliverFloatingHeader.snapMode (#151289)
When a user scroll gesture ends, Material Design floating headers snap into place by animating as far as needed and overlaying the underlying scrollable content. For example Gmail's search header works this way.  Other apps handle the snap animation by scrolling content out of the way. Instagram for example.

Added `SliverFloatingHeader.snapMode`, whose value can be `FloatingHeaderSnapMode.overlay` (the default) or `FloatingHeaderSnapMode.scroll`, so that developers can choose the snap animation style they want.

| FloatingHeaderSnapMode.overlay | FloatingHeaderSnapMode.scroll |
| --- | --- |
| <video src="https://github.com/flutter/flutter/assets/1377460/05c82ddf-05a6-4431-9b1e-88b901feea68" /> | <video src="https://github.com/flutter/flutter/assets/1377460/fedc34de-0b55-4f0d-976f-2df1965c90bc" /> |
2024-07-08 19:33:14 +00:00
Taha Tesser
f080102350
[Reland] - Enable explicitChildNodes for the AlertDialog content (#149597)
Fixes the semantics of AlertDialog.
2024-07-08 09:47:20 -07:00
Vincent Velociter
6e246ac854
Cupertino transparent navigation bars (#149102)
This PR is making the `CupertinoNavigationBar` and `CupertinoSliverNavigationBar` appear transparent as long as the content is not scrolled under them, so they look like standard iOS apps nav bars.

https://github.com/flutter/flutter/assets/423393/eee2700b-2a91-4577-922c-6163d47cb357

https://github.com/flutter/flutter/assets/423393/3847f2b5-0dac-4d5e-aa6f-03c1d2893e30

<details>
  <summary>Demo app code</summary>
  
  ```dart
import 'package:flutter/cupertino.dart';

/// Flutter code sample for [CupertinoTabScaffold].

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

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

  @override
  State<TabScaffoldApp> createState() => _TabScaffoldAppState();
}

class _TabScaffoldAppState extends State<TabScaffoldApp> {
  Brightness _brightness = Brightness.light;

  @override
  Widget build(BuildContext context) {
    return CupertinoApp(
      theme: CupertinoThemeData(brightness: _brightness),
      home: TabScaffoldExample(
          brightness: _brightness, onBrightnessToggle: _toggleBrightness),
    );
  }

  void _toggleBrightness() {
    setState(() {
      _brightness =
          _brightness == Brightness.light ? Brightness.dark : Brightness.light;
    });
  }
}

class TabScaffoldExample extends StatefulWidget {
  const TabScaffoldExample(
      {required this.brightness, required this.onBrightnessToggle, super.key});

  final VoidCallback onBrightnessToggle;
  final Brightness brightness;

  @override
  State<TabScaffoldExample> createState() => _TabScaffoldExampleState();
}

class _TabScaffoldExampleState extends State<TabScaffoldExample> {
  @override
  Widget build(BuildContext context) {
    return CupertinoTabScaffold(
      tabBar: CupertinoTabBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(CupertinoIcons.home),
            label: 'Home',
          ),
          BottomNavigationBarItem(
            icon: Icon(CupertinoIcons.search_circle_fill),
            label: 'Explore',
          ),
          BottomNavigationBarItem(
            icon: Icon(CupertinoIcons.person_fill),
            label: 'Profile',
          ),
          BottomNavigationBarItem(
            icon: Icon(CupertinoIcons.settings_solid),
            label: 'Settings',
          ),
        ],
      ),
      tabBuilder: (BuildContext context, int index) {
        return CupertinoTabView(
          builder: (BuildContext context) {
            return CupertinoPageScaffold(
              backgroundColor: index == 3
                  ? CupertinoColors.secondarySystemBackground
                      .resolveFrom(context)
                  : null,
              child: CustomScrollView(
                slivers: [
                  CupertinoSliverNavigationBar(
                    largeTitle: Text('Tab $index'),
                    initiallyTransparent: index != 2,
                    trailing: CupertinoButton(
                      padding: EdgeInsets.zero,
                      onPressed: widget.onBrightnessToggle,
                      child: Icon(
                        widget.brightness == Brightness.light
                            ? CupertinoIcons.moon_stars
                            : CupertinoIcons.sun_max,
                      ),
                    ),
                  ),
                  SliverSafeArea(
                    top: false,
                    sliver: SliverList.list(
                      children: [
                        CupertinoButton(
                          child: const Text('Next page'),
                          onPressed: () {
                            Navigator.of(context).push(
                              CupertinoPageRoute<void>(
                                builder: (BuildContext context) {
                                  return CupertinoPageScaffold(
                                    navigationBar: CupertinoNavigationBar(
                                      middle: Text('Inner page of tab $index'),
                                    ),
                                    child: ListView(
                                      children: [
                                        Center(
                                          child: CupertinoButton(
                                            child: const Text('Back'),
                                            onPressed: () {
                                              Navigator.of(context).pop();
                                            },
                                          ),
                                        ),
                                        if (index == 0) const _LongList(),
                                        const SizedBox(height: 20),
                                      ],
                                    ),
                                  );
                                },
                              ),
                            );
                          },
                        ),
                        if (index == 1) const _LongList(),
                        const SizedBox(height: 20),
                      ],
                    ),
                  ),
                ],
              ),
            );
          },
        );
      },
    );
  }
}

class _LongList extends StatelessWidget {
  const _LongList();

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        for (int i = 0; i < 50; i++) ...[
          CupertinoListTile(
            leading: const Icon(CupertinoIcons.book),
            title: Text('Bookstore item $i'),
          ),
        ],
      ],
    );
  }
}
  ```
</details>

This is the continuation of https://github.com/flutter/flutter/pull/142439.

I tried to keep the simplest API possible, so it's only introducing a new `automaticBackgroundVisibility` boolean parameter. 

In the implementation I had to use the `CupertinoPageScaffold` background color to make it look transparent instead of a 0 opacity, because of issues with route transitions.

I used an `InheritedWidget` so the nav bar is always getting the right background color from the parent scaffold, whether it is overridden or not. It would probably be better to make the inherited widget private but we'd need to move all the nav bar code to the same file as the scaffold, so for now I've just hidden it from the export. Let me know if it is okay to do that.

This PR is not dealing with the bottom tab bar, because the same [straightforward approach](dde8ec6dc7) doesn't work here. The problem is that the scroll notification is sent only when the scroll view is created or updated, so it doesn't work if one pushes a screen and navigates back.

Issues:
- #78607 
- #60411
2024-07-03 20:35:27 +00:00
Harry Terkelsen
8e44e94e22
Prepares semantics_update_test for upcoming link URL change (#151261)
Prepares for https://github.com/flutter/engine/pull/53507 by adding a missing parameter to the `updateNode` test method.

Part of https://github.com/flutter/flutter/issues/150263
2024-07-03 20:31:23 +00:00
Hans Muller
d1e150099e
SliverFloatingHeader (#151145)
A sliver that shows its [child] when the user scrolls forward and hides it when the user scrolls backwards. Similar headers can be found in  Google Photos and Facebook.

This sliver is preferable to the general purpose SliverPersistentHeader for its relatively narrow use case because there's no need to create a SliverPersistentHeaderDelegate or to predict the header's size.

https://github.com/flutter/flutter/assets/1377460/82b67dfb-5d38-4adf-9415-fc8527d0eb9f
2024-07-03 19:52:52 +00:00
Kishan Rathore
fbd6890fb7
Feat: Add withOpacity to gradient (#150670)
Feat: Add withOpacity to gradient because sometimes it's required to call withOpacity directly on gradient

Resolves #150501 

This adds a `withOpacity` feature to a gradient, given user has given colors this will override opacity to given opacity for them.
2024-07-03 18:06:04 +00:00
flyboy
7b69688c8a
content dimensions are not established get controller value error (#148938)
*Fixed #[146986](https://github.com/flutter/flutter/issues/146986)*
2024-07-03 17:17:28 +00:00
Jonathan Lau
5698944196
Fix scheduler event loop being stuck due to task with Priority.idle (#151168)
`handleEventLoopCallback()` should return `true` rather than `false` when there are tasks in the queue but the highest priority task is not run because of the `schedulingStrategy`. If `false` is returned when the queue still has tasks, the event loop stops, causing existing and new tasks to never be scheduled.

For full context, see https://github.com/flutter/flutter/issues/73766#issuecomment-2202427256.

Fixes #73766 and #82016.
2024-07-02 23:59:20 +00:00
Matej Knopp
348fdeebb3
Fix result propagation in RenderSliverEdgeInsetsPadding.hitTestChildren (#149825)
Fixes https://github.com/flutter/flutter/issues/149824
2024-07-02 23:21:22 +00:00
Igor Hnízdo
46030f1eff
Interactable ScrollView content when settling a scroll activity (#145848)
Currently when the user:
- flings a scrollable 
- overscrolls, and the scrollable is trying to settle
- applies `DrivenScrollActivity`
- swipes from one tab to the next

All inputs are discarded or forwarded directly to the Scrollable widget (scroll activity).

This leads to situations like these:

https://github.com/flutter/flutter/assets/12874766/51b7876f-5a91-4a86-aa21-c72f0b2c4263

https://github.com/flutter/flutter/assets/12874766/2f756a45-5e42-47d7-98a0-12f071d34e7c

https://github.com/flutter/flutter/assets/12874766/5eb998a1-b3b8-42a1-8b04-543f68823c2b

Which leads to poor experience on iOS. The native behavior of iOS is to allow touches while a scrollable is settling:

https://github.com/flutter/flutter/assets/12874766/e1ae61f8-d59c-40ae-a4c4-ad919f0dc6bf

This PR alters the `shouldIgnoreTouches` of `BallisticScrollAvtivity` and `DrivenScrollActivity` to not make the child of the scrollable ignore touches.

Fixes #145330

Currently tests that test tap to stop are not working as the taps now register when they should not. Because there is no distinction between flings inside and flings that go out of range.
2024-07-02 23:01:44 +00:00
Tong Mu
b6163726a1
Fix: CupertinoActionSheet should take up max height when actions section is short (#150708)
This PR addresses a bug from the previous rewrite of the `CupertinoActionSheet` height allocation algorithm. 

The previous approach assigns the content section with a minimal height. As a result, if the actions section is shorter than `_kActionSheetActionsSectionMinHeight`, the remaining space will not be taken by the content section.

As far as I know, this algorithm can not be implemented by simply compositing simple layout widgets, and therefore I created a new widget `_PriorityColumn` that uses a custom layout algorithm. (The resulting code is still shorter (and cleaner) than before the rewrite!)

Some other trivial refactor is also done to clean up the code around parameters of `_ActionSheetMainSheet`.
2024-07-02 04:47:37 +00:00