3828 Commits

Author SHA1 Message Date
Bernardo Ferrari
ce63c029c5
Fix anti-aliasing when painting borders with solid colors. (#153365)
Trying to reland https://github.com/flutter/flutter/pull/122317 in 2024. Let's see if we can.

<img width="666" alt="image" src="https://user-images.githubusercontent.com/351125/182002867-03d55bbb-163d-48b9-ba3c-ed32dbef2680.png">

Side effect: shapes with border will be rounder:
![Frame 6](https://github.com/user-attachments/assets/95324ebc-8db5-4365-817f-bc62304b9044)

Close https://github.com/flutter/flutter/issues/13675.
2024-08-15 19:02:23 +00:00
Qun Cheng
108a355453
Update tokens to 5.0.0 (#153385)
This PR is to
* Update the Material Design tokens to 5.0.0
* 4 color roles in **Light mode** have different default values
   `onPrimaryContainer`: Primary10  -> Primary30 
   `onSecondaryContainer`: Secondary10 -> Secondary30
   `onTertiaryContainer`: Tertiary10 -> Tertiary30
   `onErrorContainer`: Error10 -> Error30
    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;![Screenshot 2024-08-13 at 12 53 03 PM](https://github.com/user-attachments/assets/bfa863d9-03d3-4557-8676-d56febdb2be5)

* new tokens added in list.json
* `md.comp.menu.list-item.*` tokens are deprecated and should be replaced by tokens in list.json and we've done the migration last year:)!(#122388)
2024-08-14 22:53:36 +00:00
Denis Bowen
51c640297f
Slider shows visual label of value on focus (#152960)
Fixed issue to where value indicator label is not shown to user when initially focused.

Before:  [Screen recording 2024-08-05 12.16.24 PM.webm](https://github.com/user-attachments/assets/806e94d7-7c6c-40e5-93af-dbf2fb9e0dd4)
After: https://screencast.googleplex.com/cast/NTY5NzIzMTYxNjIxMjk5MnxkY2IyMGNkYi1iZA

Fixes https://github.com/flutter/flutter/issues/113538
2024-08-14 18:27:14 +00:00
PurplePolyhedron
b5847d364a
Delay DropdownMenu filtering until text input (#152368)
fixes https://github.com/flutter/flutter/issues/152055

Disabling filtering in `DropdownMenu` at start and after a selection has been made, and re-enable it (if `widget.enableFilter` is true) after text input.
This way it doesn't hide all other options when there is an existing selection.

Note: currently this may crush due to issue https://github.com/flutter/flutter/issues/151878 . Which is not directly related to this PR
2024-08-14 18:06:14 +00:00
Bruno Leroux
5609019500
Expose affixes icon constraints in InputDecorationTheme (#153089)
## Description

This PR makes the existing `InputDecoration.prefixIconConstraints` and `InputDecoration.suffixIconConstraints` configurable from an `InputDecorationTheme`.

## Related Issue

Related to https://github.com/flutter/flutter/issues/138691 (this is needed before providing a fix or a workaround for it).

## Tests

Update and split one existing test into two different tests.
Update the existing test related to debugFillDescription by adding all the non tested properties.
2024-08-09 22:04:56 +00:00
yim
14cd5fa30a
The PopupMenuButton should not steal focus from the TextField when it appears. (#150568)
Fixes: #24843
Fixes: #50567
2024-08-08 16:09:18 +00:00
Bruno Leroux
64b373b1f2
Clean up MenuAnchor (#152946)
## Description

This PR cleans up some typos and formatting issues in the `material/menu_anchor.dart` file and associated tests.
2024-08-07 23:39:24 +00:00
Tyler Holland
88fa6210ad
Allow dropdown_menu to accept any EdgeInsetsGeometry (#153053)
Allow dropdown_menu to accept any EdgeInsetsGeometry instead of just strictly EdgeInsets.

This follows normal Flutter widget practices when accepting a padding parameter, like Container: https://github.com/flutter/flutter/blob/main/packages/flutter/lib/src/widgets/container.dart#L307C9-L307C27

Fixes https://github.com/flutter/flutter/issues/151769
2024-08-07 21:38:34 +00:00
davidhicks980
1f4c6ebc97
MenuAnchor hover traversal fixes (#150914)
Fixes https://github.com/flutter/flutter/issues/150910 and https://github.com/flutter/flutter/issues/150911. 

https://github.com/flutter/flutter/issues/150910 is fixed by invalidating the focus scope whenever a hover occurs. I'm interested to hear of better fixes -- it feels a bit extreme to invalidate the focus scope so often.

https://github.com/flutter/flutter/issues/150911 is fixed by replacing TextButton.onHover with MouseRegion.onHover and MouseRegion.onExit. The issue appears to be that MouseRegion.onEnter is called on scroll, whereas MouseRegion.onHover is not. I'm not confident this is a great solution, so please let me know if you all have any suggestions!

@Piinks @dkwingsmt
2024-08-07 17:43:00 +00:00
davidhicks980
faabe3af72
[material/menu_anchor.dart] MenuAnchor focus refactoring for RawMenuAnchor (#150950)
This PR is aimed at (1) reducing the private API surface of _MenuAnchorState to make migration into RawMenuAnchor simpler, and (2) fixing focus-related bugs. 

Directional focus handling was moved from MenuAnchor (_MenuDirectionalFocusAction, _MenuNextFocusAction, and _MenuPreviousFocusAction) into SubmenuButton (_SubmenuDirectionalFocusAction). MenuAnchor now behaves similarly to a flat FocusScope, which makes it easier to customize. A future PR will ideally expose or remove the remaining internals (_lastItemFocusNode, _firstItemFocusNode, _isRoot, etc). All previous framework tests are passing, and additional tests were added for fixes (MenuAnchor tab traversal, reopened menus not being focusable), and to test MenuAnchor focus behavior separately from MenuBar. 

However, [one example test](https://github.com/flutter/flutter/pull/150950/files#diff-a33fa01b59d280784e7c8ed6b704bd005cde95b7d3b649dc82fd58530061a09d) had to be changed. I'm not sure why the previous example test was working to begin with, as submenu buttons are supposed to open on focus, but this behavior was not observed in the original test. 

Fixes https://github.com/flutter/flutter/issues/144381, https://github.com/flutter/flutter/issues/150334.

One added feature is the ability to move between top-level horizontal submenus if a horizontal movement is made on a vertical menu item that has no children in the movement direction. This behavior was observed on Google Docs, MacOS, and various other menu systems I encountered.

https://github.com/flutter/flutter/assets/59215665/04a42b8a-cc9e-4a50-9d0c-6f2d784cfc78
2024-08-06 19:04:11 +00:00
Gazal
6f98b485ec
fix: add parameter to maintainState of SearchDelegate (#152444)
Add parameter to `showSearch`, which is passed to `_SearchPageRoute` to maintain the state of the SearchDelegate.

- fix #43582

_Just contributed this change to start the conversation on how the #43582 can be addressed. Have not added tests yet._
2024-08-06 17:53:03 +00:00
Denis Bowen
93b55edff1
Slider does not show changed label value for keyboard users fix (#152886)
Fix issue to where keyboard users could not see visual indicator label of changed value in Slider

Before: 
[Screen recording 2024-08-05 12.16.24 PM.webm](https://github.com/user-attachments/assets/89b99423-7856-4b25-86de-b211b2dbe178)

After:
[Screen recording 2024-08-05 12.38.20 PM.webm](https://github.com/user-attachments/assets/641f9065-8279-4b79-89b1-b5bcd3d691a8)

Fixes https://github.com/flutter/flutter/issues/152884
Fixes b/340638215
2024-08-06 16:58:07 +00:00
Qun Cheng
173bf86b7b
Fix CarouselView rebuild (#152791)
Fixes https://github.com/flutter/flutter/issues/152787

Originally, when we want to update `itemExtent`, we didn't check if the old itemExtent is null but `getItemFromPixels()` needs that information.
https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/material/carousel.dart#L1343-L1347
Then in `getItemFromPixels()`, it goes to the else statement which assert `flexWeights` is not null, then the exception happens.

- [x ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
2024-08-05 23:04:48 +00:00
Greg Spencer
51ed348f3b
Fix handling of iconSize and iconColor defaults for ButtonStyleButton subclasses. (#143501)
## Description

Adds defaults that use tokens to define default `iconSize` and `iconColor` values. Previously, the Material 3 token values for button icon sizes and colors were not being used as defaults when the `ButtonStyleButton.defaultStyleOf` function returned the default values.

Adds tests to make sure appropriate `ButtonStyle` fields are populated when defaultStyle is called on buttons.

Updated documentation for `defaultStyleOf` to indicated that not _all_ fields need to be non-null, since some fields make sense to be null (e.g. `fixedSize`) because they would otherwise override the behavior of other fields in the same `ButtonStyle`.

## Tests
 - Added tests to make sure that the appropriate fields are non-null in the default button styles for each type of button.
2024-08-02 23:31:07 +00:00
Tirth
d6e4555494
Quick Grammar Fixes (#152744)
Quick Grammar Fixes
2024-08-02 21:16:24 +00:00
Justin McCandless
67a958568e
SearchBar.scrollPadding (#152635)
Pass through the missing scrollPadding parameter for SearchBar and SearchAnchor.bar.
2024-08-01 13:56:04 -07:00
Nate Wilson
788a0e3d2f
Implementing null-aware logic in /packages/flutter/ (#152294)
Hopefully soon, [flutter.dev/go/dart-patterns](https://flutter.dev/go/dart-patterns) will have lots of good feedback; in the meantime, I'll focus refactoring efforts on uncontroversial things :)

Previously, I was under the impression that I could solve issue #143803 with [just 1 PR](https://github.com/flutter/flutter/pull/143804).
It turns out that I had overlooked quite a bit!

<br>

```dart
// before
if (chunkEvents != null) {
  chunkEvents.listen((ImageChunkEvent event) {
      reportImageChunkEvent(event);
    },
  );
}

// after
chunkEvents?.listen(reportImageChunkEvent);
```
2024-07-31 23:35:24 +00:00
Taha Tesser
0d154e55d1
Add ability to clip Stepper step content (#152370)
fixes [Dismissible content overlays Stepper interface while dismissing it](https://github.com/flutter/flutter/issues/66007)

### 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> {
  final List<String> items =
      List<String>.generate(20, (int i) => 'Item ${i + 1}');

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Padding(
          padding: const EdgeInsets.all(20),
          child: DecoratedBox(
            decoration: BoxDecoration(
              border: Border.all(color: Colors.amber, width: 2),
            ),
            child: Padding(
              padding: const EdgeInsets.all(2.0),
              child: Column(
                children: <Widget>[
                  const SizedBox(height: 8.0),
                  Text(
                    'Dismissible Widget - Vertical Stepper Widget',
                    style: Theme.of(context).textTheme.titleLarge,
                  ),
                  Expanded(
                    child: Stepper(
                      clipBehavior: Clip.hardEdge,
                      steps: <Step>[
                        Step(
                          isActive: true,
                          title: const Text('Step 1'),
                          content: ColoredBox(
                            color: Colors.black12,
                            child: ListView.builder(
                              itemCount: items.length,
                              shrinkWrap: true,
                              itemBuilder: (BuildContext context, int index) {
                                final String item = items[index];
                                return Dismissible(
                                  key: Key(item),
                                  onDismissed: (DismissDirection direction) {
                                    setState(() {
                                      items.removeAt(index);
                                    });
                                    ScaffoldMessenger.of(context).showSnackBar(
                                        SnackBar(
                                            content: Text('$item dismissed')));
                                  },
                                  background: Container(color: Colors.red),
                                  child: ListTile(title: Text(item)),
                                );
                              },
                            ),
                          ),
                        ),
                        const Step(
                          title: Text('Step 2'),
                          content: Text('content'),
                        ),
                      ],
                    ),
                  ),
                  const Divider(height: 1),
                  const SizedBox(height: 8.0),
                  Text(
                    'Dismissible Widget - Horizontal Stepper Widget',
                    style: Theme.of(context).textTheme.titleLarge,
                  ),
                  Expanded(
                    child: Stepper(
                      clipBehavior: Clip.hardEdge,
                      type: StepperType.horizontal,
                      elevation: 0.0,
                      steps: <Step>[
                        Step(
                          isActive: true,
                          title: const Text('Step 1'),
                          content: ColoredBox(
                            color: Colors.black12,
                            child: ListView.builder(
                              itemCount: items.length,
                              shrinkWrap: true,
                              itemBuilder: (BuildContext context, int index) {
                                final String item = items[index];
                                return Dismissible(
                                  key: Key(item),
                                  onDismissed: (DismissDirection direction) {
                                    setState(() {
                                      items.removeAt(index);
                                    });
                                    ScaffoldMessenger.of(context).showSnackBar(
                                        SnackBar(
                                            content: Text('$item dismissed')));
                                  },
                                  background: Container(color: Colors.red),
                                  child: ListTile(title: Text(item)),
                                );
                              },
                            ),
                          ),
                        ),
                        const Step(
                          title: Text('Step 2'),
                          content: Text('content'),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}
```

</details>

### Without `Stepper` step content clipping

![Group 1](https://github.com/user-attachments/assets/1814ad90-8d43-4e03-9f68-7da47e08c718)

### With `Stepper` step content clipping

![Group 2](https://github.com/user-attachments/assets/652ff597-7e9a-4d35-abc2-80d60cee03f4)
2024-07-31 19:58:04 +00:00
Mitchell Goodwin
91a3f69f11
Calendar font factor (#152341)
Increases the max text can be scaled for the date picker in calendar mode and input mode. Previously the max across the whole widget was 1.3. Due to the size of the widget, this was increased as much as possible with different values used in different places. Testing and screenshots where taken on the iPhone SE 3rd generation simulator, set at max font size, which is a value of 3.0. Android has a lower max font scale value of 2.0, and the iPhone SE is about the smallest phone with a lower pixel density ratio.

Fixes internal issues b/316958515 and b/316959677 
Also fixes #61334

Comparison for calendar mode in portrait and landscape:

| Before    | After |
| -------- | ------- |
| <img width="375" alt="Old-SE-Portrait-DayPicker" src="https://github.com/user-attachments/assets/4dd1735f-f4c7-4a0a-b8d3-e5ea84d2ba3c"> | <img width="376" alt="Screenshot 2024-07-25 at 1 25 41 PM" src="https://github.com/user-attachments/assets/a53d7d68-87ef-4b29-9479-36ef22bd6cc9"> |
| <img width="375" alt="Old-SE-Portrait-YearPicker" src="https://github.com/user-attachments/assets/37c2965d-1ec0-429b-aa4d-37396f90cb74"> | <img width="377" alt="Screenshot 2024-07-25 at 1 26 38 PM" src="https://github.com/user-attachments/assets/2a00d90f-d523-4ff5-a1d7-e1bfafb245d3"> |
| <img width="665" alt="Old-SE-Landscape-DayPicker" src="https://github.com/user-attachments/assets/1cc4cd26-d56a-4f35-88b1-1c13fa460c2f"> | <img width="665" alt="Screenshot 2024-07-25 at 1 25 52 PM" src="https://github.com/user-attachments/assets/729ac66c-d6b9-4a2a-8303-b5c9face0f62"> |
| <img width="664" alt="Old-SE-Landscape-YearPicker" src="https://github.com/user-attachments/assets/f00a9ab8-1925-4c33-bfcc-31020b2858b8"> | <img width="666" alt="Screenshot 2024-07-25 at 1 26 47 PM" src="https://github.com/user-attachments/assets/d6116c20-4862-4e07-8ab4-fb8ecb71bfa5"> |

The title text is smaller when the entry mode button is available:
<img width="374" alt="Screenshot 2024-07-25 at 1 24 52 PM" src="https://github.com/user-attachments/assets/83305c11-97d5-4986-bf51-fe0be71f653e">

Adjustments were made to input mode as well, but they are simpler

<img width="372" alt="Screenshot 2024-07-25 at 1 43 39 PM" src="https://github.com/user-attachments/assets/2440cf6f-160f-4689-978e-d0a3df2db102">
<img width="666" alt="Screenshot 2024-07-25 at 1 43 48 PM" src="https://github.com/user-attachments/assets/e8d8dbf3-c7d8-4668-9245-7b5036165e75">

Date range picker was not adjusted with this PR. It still has a max of 1.3.
2024-07-31 19:56:15 +00:00
Bruno Leroux
1a8e57f42e
Use decoration hint text as the default value for dropdown button hints (#152474)
## Description

This PR makes `DropdownButtonFormField` hint defaults to the provided inputDecoration hintText.

Because `DropDownButtonFormField` accepts both a `hint` parameter and a `decoration`parameter, one can expect `InputDecoration.hintText` to be valid.

Before this PR, when `InputDecoration.hintText` was specified, it is shown but the vertical position is wrong.
After this PR, when `InputDecoration.hintText` is specified, it is used as the default value for `DropDownButtonFormField.hint` and `DropDownButtonFormField.disabledHint`.

| Before | After |
|--------|--------|
| ![image](https://github.com/user-attachments/assets/a08ff75c-edd4-4e16-9cfa-98ddb349d860) | ![image](https://github.com/user-attachments/assets/55f08bee-8f88-4125-8fae-68e2be724955) |

## Related Issue

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

## Tests

Adds 5 tests.
2024-07-31 11:22:26 +00:00
hangyu
dc6a15995e
Reland #151599 (Add button semantics in list tile ) with a flag to control behavior. (#152526)
https://github.com/flutter/flutter/pull/151599 was reverted because it was a breaking change to g3

Will reland 151599 in 5 steps 
1. Make changes with an additional parameter ( bool internalAddSemanticForOnTap = false)  
2. Send regular CLs in google3 to pass internalAddSemanticForOnTap: true, and update the tests / text goldens accordingly.
3. Send a PR to flip the default value to true.
4. Send CLs internally to remove internalAddSemanticForOnTap: true.
5. Send another PR to remove the now-redundant internalAddSemanticForOnTap flag.

 (<----This PR is step 1)
2024-07-30 20:38:06 +00:00
Taha Tesser
cd60efc618
Fix default avatar icon theme size for Material 2 (#152307)
fixes [ActionChip avatar still does not respect padding](https://github.com/flutter/flutter/issues/116508)

### 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(
      theme: ThemeData(brightness: Brightness.dark, useMaterial3: false),
      home: Scaffold(
        body: Center(
          child: Builder(
            builder: (BuildContext context) {
              return Chip(
                padding: const EdgeInsets.all(16.0),
                avatar: const Icon(Icons.favorite),
                label: const Text('Chip A'),
                onDeleted: () {},
              );
            },
          ),
        ),
      ),
    );
  }
}
```

</details>

### Before

<img width="490" alt="Screenshot 2024-07-25 at 16 24 08" src="https://github.com/user-attachments/assets/45408aa2-b3ab-4ff9-ae72-53a91c87c76a">

### After

<img width="490" alt="Screenshot 2024-07-25 at 16 23 56" src="https://github.com/user-attachments/assets/07ba367d-9ca3-46cc-8122-d1155dd2f32b">
2024-07-30 16:44:08 +00:00
Bruno Leroux
85960d24b9
Fix Shortcut label for CharacterActivator does not include modifiers (#152233)
## Description

This PR fixes the shortcut label for CharacterActivator with modifiers keys.

**Before**:

![image](https://github.com/user-attachments/assets/1cb8defe-2600-45ef-878d-fbdde5aaf2ad)

**After**:

![image](https://github.com/user-attachments/assets/cd3b1c79-2f23-40fd-b0b9-934fa182fff3)

## Related Issue

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

## Tests

Adds 1 test.
2024-07-30 07:03:00 +00:00
Greg Spencer
b05c2fad0c
Add find.backButton finder and StandardComponentType enum to find components in tests. (#149349)
## Description

This adds `find.backButton()` in the Common Finders to allow finding different types of standard UI elements. It works by attaching a key made from an enum value in a new enum called `StandardComponentType` to all of the standard widgets that perform the associated function.

I also substituted the finder in several places where it is useful in tests.

This allows writing tests that want to find the "back" button without having to know exactly which icon the back button uses under what circumstances.  To do it correctly is actually quite complicated, since there are several adaptations that occur (based on platform, and whether it is web or not).

## Tests
 - Added tests.
2024-07-30 01:29:31 +00:00
Qun Cheng
2e7fa83f67
Normalize Card theme (#151914)
This PR is to make preparations to make `CardTheme` conform to Flutter's conventions for component themes:
* Added a `CardThemeData` class which defines overrides for the defaults for `Card` properties.
* Added 2 `CardTheme` constructor parameters: `CardThemeData? data` and `Widget? child`. This is now the preferred way to configure a `CardTheme`:
```dart
CardTheme(
  data: CardThemeData(color: xxx, elevation: xxx, ...),
  child: Card(...)
)
```

These two properties are made nullable to not break existing apps which has customized `ThemeData.cardTheme`.
* Changed the type of theme defaults from `CardTheme` to `CardThemeData`.

TODO: 
* Fix internal failures that may have breakages.
* Change the type of `ThemeData.cardTheme` from `CardTheme` to `CardThemeData`. This may cause breaking changes, a migration guide will be created.

Addresses the "theme normalization" sub project within https://github.com/flutter/flutter/issues/91772
2024-07-29 16:48:06 +00:00
auto-submit[bot]
e8d4c98b07
Reverts "Add button semantics in list tile (#151599)" (#152425)
Reverts: flutter/flutter#151599
Initiated by: chingjun
Reason for reverting: broke an internal test.
Original PR Author: hangyujin

Reviewed By: {chunhtai}

This change reverts the following previous change:
fixes: https://github.com/flutter/flutter/issues/111960
2024-07-27 04:40:17 +00:00
hangyu
37dff27324
Add button semantics in list tile (#151599)
fixes: https://github.com/flutter/flutter/issues/111960 

## 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-07-26 16:34:53 -07:00
Kishan Rathore
f6144f0c25
feat: Add drag handle size to be configurable based on given size (#152085)
Feat: Drag handle size can now be changed to any given size.
So, In previous behaviour drag handle size was not able to extends beyond 48x48. But some user might want to change it.
In current behaviour,  drag handle size is default to same 48x48 but if drag handle size grows beyond that, we don't restrict it.

Fixes #149170
2024-07-26 16:15:36 +00:00
Taha Tesser
bba6ea9a2d
Introduce TabBar.indicatorAnimation to customize tab indicator animation (#151746)
fixes [Add ability to customize `TabBar` indicator animation](https://github.com/flutter/flutter/issues/150508)

Similar option exist on Android
https://developer.android.com/reference/com/google/android/material/tabs/TabLayout#setTabIndicatorAnimationMode(int)

### Dartpad Example Preview
<img width="874" alt="Screenshot 2024-07-12 at 17 36 08" src="https://github.com/user-attachments/assets/e349c5aa-ee5d-46ce-9e44-4f02346603bd">

### Linear vs Elastic tab indicator animation

https://github.com/user-attachments/assets/d7ae3ae4-ae52-4ccd-89b1-75908bf8a34d
2024-07-26 11:54:28 +00:00
Bruno Leroux
d8ef702714
Cleanup InputDecoration.collapsed constructor (#152165)
## Description

This PR attemps to clarify the `InputDecoration.collapsed` documentation by explaining that it is not meant to be use with helper, label, counter, icons, prefixes and suffixes.

It also adds some parameters that make sense for a collapsed decoration (`hintMaxLines`, `hintFadeDuration`, `constraints`).

Removing parameters that should not have been added (`floatingLabelBehavior` and `floatingLabelAlignment`) will be part of another PR as it will require deprecations.

## Related Issue

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

## Tests

Adds 3 tests.
2024-07-25 20:51:00 +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
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
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
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
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
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
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
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
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
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
Taha Tesser
f080102350
[Reland] - Enable explicitChildNodes for the AlertDialog content (#149597)
Fixes the semantics of AlertDialog.
2024-07-08 09:47:20 -07:00
Nate Wilson
d07a165d22
Implementing a few switch statements (#150946)
I really like how patterns can be used for variable assignment and avoiding duplicated logic. (related: #150942)

```dart
// before
final GestureRecognizer? recognizer = info.recognizer;
if (recognizer is TapGestureRecognizer) {
  if (recognizer.onTap != null) {
    configuration.onTap = recognizer.onTap;
    configuration.isLink = true;
  }
} else if (recognizer is DoubleTapGestureRecognizer) {
  if (recognizer.onDoubleTap != null) {
    configuration.onTap = recognizer.onDoubleTap;
    configuration.isLink = true;
  }
}

// after
switch (info.recognizer) {
  case TapGestureRecognizer(:final VoidCallback? onTap):
  case DoubleTapGestureRecognizer(onDoubleTap: final VoidCallback? onTap):
    if (onTap != null) {
      configuration.onTap = onTap;
      configuration.isLink = true;
    }
}
```
2024-07-01 23:36:32 +00:00
Jason Simmons
1ebbb9d711
Fix teardown of a FocusScopeNode in material/app_test (#151115)
This test suite had been failing when run with --test-randomize-ordering-seed=20240701
2024-07-01 17:06:54 +00:00