Commit Graph

930 Commits

Author SHA1 Message Date
derdilla
7fb7192304
Test remaining transitions api examples (#148302)
Adds tests for `relative_positioned_transition`, `positioned_transition`, `sliver_fade_transition`, `align_transition`, `animated_builder`, `rotation_transition`, `animated_widget`, `slide_transition`, `listenable_builder`, `scale_transition`, `default_text_style_transition`, `decorated_box_transition`, `size_transition` api examples. Makes double type in the `align_transition` example explicit.

A test for `fade_transition` is already in currently open #148178.

Part of #130459.
2024-05-23 18:57:14 +00:00
derdilla
aaa4d336f6
Test snack bar examples (#147774)
Adds tests to the last two Snack Bar examples as part of #130459. Makes the [last example](https://api.flutter.dev/flutter/material/SnackBar-class.html#material.SnackBar.3) more usable through the use of standard widgets and visual hierarchy. Constraints on options that are not required by the SnackBar contract have been removed (Overflow threshold works on fixed SnackBars).
2024-05-23 18:54:11 +00:00
derdilla
1c1516c35e
Add tests for material banner example (#147733)
Part of https://github.com/flutter/flutter/issues/130459.
2024-05-23 18:48:09 +00:00
huycozy
e467289fb8
Fix DecoratedSliver sample code to reflect the description (#148621)
### Demo screenshot

![Screenshot 2024-05-19 at 05 42 35](https://github.com/flutter/flutter/assets/104349824/6b4aec1f-32ab-496e-ab20-458c2051055d)

### Related issue

- Fixes https://github.com/flutter/flutter/issues/145935
- Add test for `examples/api/test/widgets/sliver/decorated_sliver.0_test.dart` as a part of https://github.com/flutter/flutter/issues/130459.
2024-05-23 08:52:15 +00:00
derdilla
abad37204e
Test raw autocomplete api examples (#148234)
Part of #130459.
2024-05-23 08:52:13 +00:00
Valentin Vignal
84876e58ce
Add test for scaffold.0.dart and scaffold.2.dart (#148166)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds test for
- `examples/api/lib/material/scaffold/scaffold.0.dart`
- `examples/api/lib/material/scaffold/scaffold.2.dart`

It also modifies the `scaffold.1_test.dart` because the only difference with scaffold 0 is the background color, so I figured the test should include it
2024-05-23 08:50:18 +00:00
Kostia Sokolovskyi
3beeed4929
Add tests for restorable_value.0.dart API example. (#148676)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Updates `examples/api/lib/widgets/restoration_properties/restorable_value.0.dart` to meet the latest API examples structure
- Adds tests for `examples/api/lib/widgets/restoration_properties/restorable_value.0.dart`
2024-05-23 08:34:23 +00:00
Kostia Sokolovskyi
112e8b5509
Add tests for actions.0.dart API example. (#148678)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Updates `examples/api/lib/widgets/actions/actions.0.dart` to meet the latest API examples structure
- Adds tests for `examples/api/lib/widgets/actions/actions.0.dart`
2024-05-22 07:25:21 +00:00
Valentin Vignal
357bd65749
Add test for undo_history_controller.0.dart (#148205)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds test for `examples/api/test/widgets/undo_history/undo_history_controller.0_test.dart`.
2024-05-21 22:19:04 +00:00
derdilla
e0533caeb7
Add test for focus example 2 (#147624)
Part of #130459. Adds tests to [the last focus example](https://api.flutter.dev/flutter/widgets/Focus-class.html#widgets.Focus.3).
2024-05-21 18:53:55 +00:00
derdilla
1635e6417d
Adds tests to NestedScrollView examples (#148170)
Part of #130459.
2024-05-21 16:35:04 +00:00
Nate
870c5541c3
switch expressions: finale (#148711)
### fixes #136139

<br>

<details open> <summary><b>getting sentimental in the PR description</b> (click to collapse)<br><br></summary>

The past 7 months have been quite the journey—I made some huge blunders and some huge accomplishments—a very fun time overall.

I really appreciate the people who took the time to perform code review for my refactoring shenanigans: **christopherfujino**, **andrewkolos**, **LongCatIsLooong**, **gspencergoog**, **loic-sharma**, **Piinks**, **bernaferrari**, **bartekpacia**, **bleroux**, **kevmoo**, **rakudrama**, **XilaiZhang**, **QuncCccccc**, **MominRaza**, and **victorsanni**.

And a huge shoutout to 2 individuals:
- @justinmc, for offering to sponsor me for commit access (words could not describe my excitement)
- @goderbauer, for being super duper proactive and consistent with code review

<br>

</details>

This pull request makes 13 "switch statements → switch expressions" PRs in total, reducing the LOC in this repo by **1,974**!

From now on, I'll make sure to request a test exemption for each refactoring PR 🙂
2024-05-21 16:18:05 +00:00
Kostia Sokolovskyi
d9cf066191
Add tests for shared_app_data.#.dart API examples. (#147830)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Updates `examples/api/lib/widgets/shared_app_data/shared_app_data.0.dart` to meet latest API examples structure
- Updates `examples/api/lib/widgets/shared_app_data/shared_app_data.1.dart` to meet latest API examples structure
- Adds tests for `examples/api/lib/widgets/shared_app_data/shared_app_data.0.dart`
- Adds tests for `examples/api/lib/widgets/shared_app_data/shared_app_data.1.dart`
2024-05-20 17:49:04 +00:00
Kostia Sokolovskyi
6cb9119148
Add tests for logical_key_set.0.dart API example. (#147735)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Corrects the name for `examples/api/test/widgets/shortcuts/logical_key_set.0_test.dart` test file
- Update tests for `examples/api/lib/widgets/shortcuts/logical_key_set.0.dart`
2024-05-20 17:47:10 +00:00
Kostia Sokolovskyi
e43fb59095
Fix painting API examples tests directories structure. (#148177)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Fixes directories structure for the existing painting API examples tests
2024-05-20 17:44:37 +00:00
Nate
76a07a1646
Implement new AnimationStatus getters (#148570)
PR #147801 introduced some convenient `AnimationStatus` getters, but I just realized that `AnimationController` now has 2 getters for the same thing: `isAnimating` and `isRunning`.

The intent of this pull request is to correct that mistake, and implement the getters in the appropriate places.
2024-05-20 17:43:03 +00:00
Nate
73ecc8a9b2
Reland "if chains → switch expressions" (#148634)
I did a goof a while back:

![late initialization error](https://github.com/flutter/flutter/assets/10457200/47dc423f-0dd0-4869-9a11-59cb7d1ea46e)

Now that [the bug is fixed](e9d403541f), I think we're good to re-implement the if-chains cleanup!

Related:

- https://github.com/flutter/flutter/pull/147793
- https://github.com/flutter/flutter/pull/148556
- https://github.com/flutter/flutter/issues/148548
2024-05-20 17:43:00 +00:00
Kostia Sokolovskyi
02a6c91e4d
Add test for image.error_builder.0.dart API example. (#148497)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds tests for `examples/api/lib/widgets/image/image.error_builder.0.dart`
2024-05-20 16:11:20 +00:00
Kostia Sokolovskyi
03e6cfa7b1
Add test for tab_controller.1.dart API example. (#148189)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Updates `examples/api/lib/material/tab_controller/tab_controller.1.dart` to properly remove the listener from the `TabController`
- Adds tests for `examples/api/lib/material/tab_controller/tab_controller.1.dart`
2024-05-20 15:33:16 +00:00
Kostia Sokolovskyi
6067d8f219
Add test for fade_transition.0.dart API example. (#148178)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds disposal of the `CurvedAnimation` in `examples/api/test/widgets/transitions/fade_transition.0.dart`
- Adds tests for `examples/api/lib/widgets/transitions/fade_transition.0.dart`
2024-05-20 10:00:40 +00:00
Kostia Sokolovskyi
538625ad38
Add tests for scaffold.of.#.dart API examples. (#147637)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds tests for `examples/api/lib/material/scaffold/scaffold.of.0.dart`
- Adds tests for `examples/api/lib/material/scaffold/scaffold.of.1.dart`
2024-05-20 08:02:09 +00:00
Zachary Anderson
597462a3c4
Revert "if chains → switch expressions" (#148556)
Reverts flutter/flutter#147793

Introduced https://github.com/flutter/flutter/issues/148548.
2024-05-17 10:27:02 -07:00
Valentin Vignal
1732994167
Add test for material_banner.0.dart and material_banner.1.dart (#148452)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds test for
- `examples/api/lib/material/banner/material_banner.0.dart`
- `examples/api/lib/material/banner/material_banner.2.dart`


## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] 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/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#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/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
[Data Driven Fixes]:
https://github.com/flutter/flutter/wiki/Data-driven-Fixes
2024-05-16 17:44:37 -07:00
Justin McCandless
8e35cf5125
Reland Native ios context menu (#143002) (#148238) (#148265)
Reverting https://github.com/flutter/flutter/pull/148238 which was relanded in https://github.com/flutter/flutter/pull/148237 which was originally from https://github.com/flutter/flutter/pull/143002.

This time post-submit I saw a failure of a wasm version of a test added by this PR.
2024-05-15 18:37:05 +00:00
derdilla
4ecc1b092b
test material text field example (#147864)
Adds simple tests to the last two [TextField](https://api.flutter.dev/flutter/material/TextField-class.html) examples as part of fixing #130459.
2024-05-14 20:46:46 +00:00
chunhtai
a36ff80cf6
Refactors page API (#137792)
fixes https://github.com/flutter/flutter/issues/137458

Chagnes:
1. Navigator.pop will always pop page based route
2. add a onDidRemovePage callback to replace onPopPage
3. Page.canPop and Page.onPopInvoked mirrors the PopScope, but in Page class.

migration guide https://github.com/flutter/website/pull/10523
2024-05-13 22:45:51 +00:00
Ellet
876aa48ea5
Use super.key instead of manually passing the Key parameter to the parent class (#147621)
*Use `super.key` instead of manually passing the `Key` parameter using super(key: key) in the constructors.*

Since if you create a widget the new default will use `super.key` instead of `Key? key : super(key: key)` this small change is to maintain the consistency, it has no semantic change

also there are some other places that might need to be updated:

![image](https://github.com/flutter/flutter/assets/73608287/898f62f5-10f9-4d76-a46c-6def328177cb)

this file for example generate l10n project and it has all the dart code as String, it might have tests that validate the output somewhere that I might miss, also there are some other places like the `_Segment` class where it require `ValueKey` instead if `Key` so I didn't update them (even though it's possible)
2024-05-13 22:12:49 +00:00
auto-submit[bot]
45e80fd63b
Reverts "Reland Native ios context menu (#143002) (#148238)" (#148254)
Reverts: flutter/flutter#148238
Initiated by: zanderso
Reason for reverting: Failures in post submit https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8748025189669617649/+/u/run_test.dart_for_web_canvaskit_tests_shard_and_subshard_3/stdout
Original PR Author: justinmc

Reviewed By: {hellohuanlin}

This change reverts the following previous change:
Reland of https://github.com/flutter/flutter/pull/143002, which was reverted in https://github.com/flutter/flutter/pull/148237 due to unresolved docs references. Not sure why those weren't caught in presubmit.

```
dartdoc:stdout: Generating docs for package flutter...
dartdoc:stderr:   error: unresolved doc reference [TextInput.showSystemContextMenu]
dartdoc:stderr:     from widgets.MediaQueryData.supportsShowingSystemContextMenu: (file:///b/s/w/ir/x/w/flutter/packages/flutter/lib/src/widgets/media_query.dart:579:14)
dartdoc:stderr:     in documentation inherited from widgets.MediaQueryData.supportsShowingSystemContextMenu: (file:///b/s/w/ir/x/w/flutter/packages/flutter/lib/src/widgets/media_query.dart:579:14)
dartdoc:stderr:   error: unresolved doc reference [showSystemContextMenu]
dartdoc:stderr:     from services.SystemContextMenuController.hide: (file:///b/s/w/ir/x/w/flutter/packages/flutter/lib/src/services/text_input.dart:2554:16)
dartdoc:stderr:   error: unresolved doc reference [hideSystemContextMenu]
dartdoc:stderr:     from services.SystemContextMenuController.show: (file:///b/s/w/ir/x/w/flutter/packages/flutter/lib/src/services/text_input.dart:2509:16)
```
2024-05-13 20:50:26 +00:00
Justin McCandless
42b3d9eb7f
Reland Native ios context menu (#143002) (#148238)
It's now possible to use the native-rendered text selection context menu on iOS. This sacrifices customizability in exchange for avoiding showing a notification when the user presses "Paste". It's off by default, but to enable, see the example system_context_menu.0.dart.
2024-05-13 12:53:36 -07:00
auto-submit[bot]
14d88ee0c8
Reverts "Native ios context menu (#143002)" (#148237)
Reverts: flutter/flutter#143002
Initiated by: cbracken
Reason for reverting: unresolved docs links. See failure here: https://ci.chromium.org/ui/p/flutter/builders/prod/Linux%20docs_test/16540/overview

```
dartdoc:stdout: Generating docs for package flutter...
dartdoc:stderr:   error: unresolved doc reference [TextInput.showSystemContextMenu]
dartdoc:stderr:     from widgets.MediaQueryData.supportsShowingSystemContextMenu: (file:///b/s/w/ir/x/w/flutter/packages/flutt
Original PR Author: justinmc

Reviewed By: {Renzo-Olivares, hellohuanlin}

This change reverts the following previous change:
In order to work around the fact that iOS 15 shows a notification on pressing Flutter's paste button (https://github.com/flutter/flutter/issues/103163), this PR allows showing the iOS system context menu in text fields.

<img width="385" alt="Screenshot 2024-02-06 at 11 52 25 AM" src="https://github.com/flutter/flutter/assets/389558/d82e18ee-b8a3-4082-9225-cf47fa7f3674">

It is currently opt-in, which a user would typically do like this (also in example system_context_menu.0.dart):

```dart
      contextMenuBuilder: (BuildContext context, EditableTextState editableTextState) {
        // If supported, show the system context menu.
        if (SystemContextMenu.isSupported(context)) {
          return SystemContextMenu.editableText(
            editableTextState: editableTextState,
          );
        }
        // Otherwise, show the flutter-rendered context menu for the current
        // platform.
        return AdaptiveTextSelectionToolbar.editableText(
          editableTextState: editableTextState,
        );
      },
```

Requires engine PR https://github.com/flutter/engine/pull/50095.

## API changes

### SystemContextMenu
A widget that shows the system context menu when built, and removes it when disposed. The main high-level way that most users would use this PR. Only works on later versions of iOS.

### SystemContextMenuController
Used under the hood to hide and show a system context menu. There can only be one visible at a time.

### MediaQuery.supportsShowingSystemContextMenu
Sent by the iOS embedder to tell the framework whether or not the platform supports showing the system context menu. That way the framework, or Flutter developers, can decide to show a different menu.

### `flutter/platform ContextMenu.showSystemContextMenu`
Sent by the framework to show the menu at a given `targetRect`, which is the current selection rect.

### `flutter/platform ContextMenu.hideSystemContextMenu`
Sent by the framework to hide the menu. Typically not needed, because the platform will hide the menu when the user taps outside of it and after the user presses a button, but it handles edge cases where the user programmatically rebuilds the context menu, for example.

### `flutter/platform System.onDismissSystemContextMenu`
Sent by the iOS embedder to indicate that the system context menu has been hidden by the system, such as when the user taps outside of the menu.  This is useful when there are multiple instances of SystemContextMenu, such as with multiple text fields.
2024-05-13 17:43:36 +00:00
Justin McCandless
125543505d
Native ios context menu (#143002)
It's now possible to use the native-rendered text selection context menu on iOS. This sacrifices customizability in exchange for avoiding showing a notification when the user presses "Paste". It's off by default, but to enable, see the example system_context_menu.0.dart.
2024-05-13 08:48:56 -07:00
derdilla
708fe97f9e
test sliver fill remaining examples (#148041)
Par of #130459. Adds tests all `SliverFillRemaining` examples.
2024-05-13 15:30:49 +00:00
Valentin Vignal
4af4cb89d5
Add test for scaffold.1.dart (#147966)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds test for `examples/api/lib/material/scaffold/scaffold.1.dart`
2024-05-11 00:37:04 +00:00
Kostia Sokolovskyi
65e8c615b4
Add test for animated_size.0.dart API example. (#147828)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Updates `examples/api/lib/widgets/animated_size/animated_size.0.dart` API example by using `SizedBox` to size the surrounding of the `FlutterLogo` while setting the constant `FlutterLogo` size. This was done because `FlutterLogo` already has size animation under the hood, and the main goal of this example is to show `AnimatedSize` usage
- Adds test for `examples/api/lib/widgets/animated_size/animated_size.0.dart`
2024-05-10 21:55:51 +00:00
Kostia Sokolovskyi
da9712f76f
Add test for draggable.0.dart API example. (#147941)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds test for `examples/api/lib/widgets/drag_target/draggable.0.dart`
2024-05-10 21:54:16 +00:00
Kostia Sokolovskyi
456d176a70
Add tests for stream_builder.0.dart API example. (#147832)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Updates `examples/api/lib/widgets/async/stream_builder.0.dart`
- Adds test for `examples/api/lib/widgets/async/stream_builder.0.dart`
2024-05-10 21:48:35 +00:00
Nate
4734d80f22
if chains → switch expressions (#147793)
Previous "if-chains" pull requests:
- https://github.com/flutter/flutter/pull/144905
- https://github.com/flutter/flutter/pull/144977
- https://github.com/flutter/flutter/pull/145194
- https://github.com/flutter/flutter/pull/146293
- https://github.com/flutter/flutter/pull/147472

<br>

I think this one should be enough to wrap things up!

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

---------

Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
2024-05-10 00:55:48 -06:00
Christopher Fujino
730d6d44b7
Don't pin package:macros (#148087)
Full context https://github.com/flutter/flutter/issues/148004

TL;DR

1. Because `package:macros` depends on `package:_macros` via [a Dart SDK
dependency](https://github.com/dart-lang/sdk/blob/main/pkg/macros/pubspec.yaml#L13);
and
2. `package:macros` exactly pins `package:_macros`; and
3. Each new version of `package:macros` will increment its exact pin of
`package:_macros`
([comment](https://github.com/flutter/flutter/issues/148004#issuecomment-2103099893));
and
4. The [flutter/flutter](https://github.com/flutter/flutter) repository
exactly pins the Dart SDK (via its exact pin on the
[flutter/engine](https://github.com/flutter/engine) repository

Therefore, the [flutter/flutter](https://github.com/flutter/flutter)
repository effectively pins both `package:macros` and `package:_macros`
already (as in, there exists only a single version of each that pub will
successfully be able to solve within the context of a particular Flutter
SDK).

Therefore, it is safe for
[flutter/flutter](https://github.com/flutter/flutter) repository to
*not* pin `package:macros`, which will allow engine -> framework rolls
that contain a new Dart SDK that contains a new `package:_macros`
version to land automatically, provided all tests pass.
2024-05-09 16:28:49 -07:00
huycozy
bd44399865
Add Badge example (#148053)
### Demo screenshot

![Screenshot 2024-05-09 at 18 47 21](https://github.com/flutter/flutter/assets/104349824/9ca4c89f-0d0a-48b2-8149-3fae73f54212)

### Related issue
Fixes https://github.com/flutter/flutter/issues/144336
2024-05-09 16:47:16 +00:00
Danny Tuppeny
cea1d6f055
Unpin DDS and roll pub packages (#147925)
DDS was temporarily pinned to 4.1.0 because 4.2.0 triggered some test
failures (see https://github.com/flutter/flutter/pull/147250). Those
failures should be fixed by vm_service 14.2.2, so this unpins DDS and
rolls both of these packages (along with devtools_shared, which is a DDS
dependency).

(If the bot updates vm_service before this is done, I can rebase over
that will reduce the size of this PR to just a few files)
2024-05-08 10:35:28 +01:00
derdilla
a7bdf369e5
improve focus example (#147464)
Part of #130459. Adds a test to the [second focus example](https://api.flutter.dev/flutter/widgets/Focus-class.html#widgets.Focus.2) and makes the function of the example more clear.
2024-05-07 20:07:49 +00:00
chunhtai
007faa980d
Reapply new PopScope API (#147607)
same as previous but with soft transition on modalroute

## 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/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#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/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
[Data Driven Fixes]:
https://github.com/flutter/flutter/wiki/Data-driven-Fixes
2024-05-07 09:04:49 -07:00
Kostia Sokolovskyi
7920a52dd5
Add tests for callback_shortcuts.0.dart API example. (#147536)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Corrects the name for `examples/api/test/widgets/shortcuts/callback_shortcuts.0_test.dart` test file
- Update tests for `examples/api/lib/widgets/shortcuts/callback_shortcuts.0.dart`
2024-05-07 15:21:46 +00:00
Kostia Sokolovskyi
28e65b7811
Add tests for shortcuts.dart API examples. (#147433)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds tests for `examples/api/lib/widgets/shortcuts/shortcuts.0.dart`
- Adds tests for `examples/api/lib/widgets/shortcuts/shortcuts.1.dart`
2024-05-07 11:25:12 +00:00
osama
774ef8acf4
Added missing tests for ButtonStyle example (#147457)
Added missing tests for ButtonStyle example. Issue #130459
2024-05-07 09:00:27 +00:00
derdilla
5ecd4ea83d
test focus example 0 (#147564)
Part of #130459. Adds tests for [Focus example 0](https://api.flutter.dev/flutter/widgets/Focus-class.html#widgets.Focus.1).
2024-05-07 01:03:09 +00:00
flutter-pub-roller-bot
c0ed9f6ff4
Roll pub packages (#147896)
This PR was generated by `flutter update-packages --force-upgrade`.
2024-05-06 23:36:21 +00:00
flutter-pub-roller-bot
d4b2e5d705
Roll pub packages (#147891)
This PR was generated by `flutter update-packages --force-upgrade`.
2024-05-06 22:39:58 +00:00
Greg Spencer
2e78ed0ff9
Allow explicit exclusion of packages from pinned packages in flutter update-packages --force-update (#147679)
## Description

This introduces a list of packages that we will explicitly not pin.  It is to be used for things where the package isn't actually published, but is a transitive dependency of another package included in the SDK.  This happens with the `macros` package, for instance, which depends on the private, unpublished, `_macros` package where the SDK does some tricky things to depend on it (it depends on "any", but ships it as part of the SDK).

Also ran `flutter update-packages --force-update` to update all of the pubspec files.

## Related Issues
 - Fixes #147656

## Tests
 - Added a test that makes sure that explicitly unpinned packages don't show up in the pinned list.
2024-05-02 01:16:54 +00:00
Kostia Sokolovskyi
32ea4b3c46
Add test for animated_fractionally_sized_box.0.dart API example. (#146721)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds `examples/api/test/widgets/implicit_animations/animated_fractionally_sized_box.0_test.dart` test
2024-05-01 16:03:12 +00:00
Kostia Sokolovskyi
d33bb8fa5e
Add tests for single_activator.0.dart API example. (#147426)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Fixes name of the `examples/api/lib/widgets/shortcuts/single_activator.single_activator.0.dart`
- Adds tests for `examples/api/lib/widgets/shortcuts/single_activator.0.dart`
2024-05-01 14:52:57 +00:00
chunhtai
3e399c1578
Revert "add a new PopScope.onPopWithResultInvoke widget to replace Po… (#147597)
…pScope.onPopInvoke (#147016)"

This reverts commit 8031a3e30c.

Needs to migrate flutter_eval

## 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/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#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/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
[Data Driven Fixes]:
https://github.com/flutter/flutter/wiki/Data-driven-Fixes
2024-04-30 13:25:24 -07:00
Taha Tesser
257df5ebfc
Add ability to disable FloatingActionButton scale and rotation animations using FloatingActionButtonAnimator.noAnimation (#146126)
fixes [[Proposal] Allow disabling the scaling animation of the FloatingActionButton](https://github.com/flutter/flutter/issues/145585)

### Using default `FloatingActionButton` animations

![ScreenRecording2024-04-02at16 19 03-ezgif com-video-to-gif-converter](https://github.com/flutter/flutter/assets/48603081/627ea564-7f60-4eb4-bed9-95c053ae2f56)

### Using `FloatingActionButtonAnimator.noAnimation`

![ScreenRecording2024-04-02at16 17 20-ezgif com-video-to-gif-converter](https://github.com/flutter/flutter/assets/48603081/d0a936ea-9e16-4225-8dc4-40a11ee8a975)
2024-04-29 08:26:19 +00:00
Kostia Sokolovskyi
9230b0e820
Add tests for character_activator.0.dart API example. (#147384)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds `examples/api/lib/widgets/shortcuts/character_activator.0.dart` test
- Fixes the description of the `examples/api/lib/widgets/shortcuts/character_activator.0.dart` example
2024-04-26 22:26:14 +00:00
Kishan Dhankecha
e4ad15900a
Added missing tests for Table api example table.0.dart. (#147318)
Added missing tests for Table example. Issue #130459
2024-04-26 21:30:17 +00:00
Greg Spencer
d274a2126f
Refactor route focus node creation (#147390)
## Description

This fixes an issue in the creation of the `FocusScope` in a route:  the route should be creating the `FocusScope` widget it has with `withExternalFocusNode`, since it is modifying the node attributes in a builder. 

Also modified some `AnimatedBuilder`s to be `ListenableBuilder`s, since they're not using animations (no functionality change there, since the implementation of the two is identical).

## Related Issues
 - #147256
 - Fixes #146844

## Tests
 - Updated example test.
2024-04-26 17:17:19 +00:00
chunhtai
8031a3e30c
add a new PopScope.onPopWithResultInvoke widget to replace PopScope.onPopInvoke (#147016)
same as https://github.com/flutter/flutter/pull/139164, but make it a soft transition
2024-04-26 04:06:11 +00:00
Kostia Sokolovskyi
9ebf80a80a
Add test for sliver_animated_opacity.0.dart API example. (#146722)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds `examples/api/test/widgets/implicit_animations/sliver_animated_opacity.0_test.dart` test
2024-04-23 22:10:50 +00:00
Kostia Sokolovskyi
f6dc1ac00d
Add test for focus_node.0.dart API example. (#146943)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds `examples/api/test/widgets/focus_manager/focus_node.0_test.dart` test
2024-04-23 20:32:07 +00:00
Kostia Sokolovskyi
ff5e2d5922
Add test for animated_align.0.dart API example. (#146719)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds `examples/api/test/widgets/implicit_animations/animated_align.0_test.dart` test
2024-04-23 19:13:14 +00:00
Kostia Sokolovskyi
b0524b354b
Add test for animated_positioned.0.dart API example. (#146720)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds `examples/api/test/widgets/implicit_animations/animated_positioned.0_test.dart` test
2024-04-23 17:16:07 +00:00
Lam Thanh Nhan
bd651347e1
Update examples/api for android platform (#147102)
In the `examples/api`, the Android platform missed this step while migrating to the declarative plugins {} block described in [flutter-gradle-plugin-apply](https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply), so all examples of `examples/api` cannot run.

Fixes #147100

*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-04-22 20:14:13 +00:00
Anis Alibegić
140edb9883
Fixed few typos (#147087)
Here's another PR with a couple of typos fixed. As you can see there was a typo in _fileReferenceI**n**dentifiers_, in class _ParsedProjectInfo._ Maybe we should do some check on that since I'm not sure if that property is used somewhere outside Flutter?
2024-04-22 16:49:19 +00:00
Kostia Sokolovskyi
142e247fab
Add tests for gesture_detector.0.dart and gesture_detector.1.dart API examples. (#146724)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds `examples/api/test/widgets/gesture_detector/gesture_detector.0_test.dart` test
- Adds `examples/api/test/widgets/gesture_detector/gesture_detector.1_test.dart` test
2024-04-19 23:08:04 +00:00
Kostia Sokolovskyi
a4e9026589
Add test for animated_padding.0.dart API example. (#146718)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds `examples/api/test/widgets/implicit_animations/animated_padding.0_test.dart` test
2024-04-19 20:16:56 +00:00
Kostia Sokolovskyi
cb3e689167
Add test for dismissible.0.dart API example. (#146723)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds `examples/api/test/widgets/dismissible/dismissible.0_test.dart` test
2024-04-19 19:21:08 +00:00
Kostia Sokolovskyi
e09ee6be9b
Add test for preferred_size.0.dart API example. (#146725)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds `examples/api/test/widgets/preferred_size/preferred_size.0_test.dart` test
2024-04-19 19:08:07 +00:00
auto-submit[bot]
bb4c9b381e
Reverts "Add generic type for result in PopScope (#139164)" (#147015)
Reverts: flutter/flutter#139164
Initiated by: chunhtai
Reason for reverting: hard breaking change
Original PR Author: chunhtai

Reviewed By: {justinmc}

This change reverts the following previous change:
Adds a generic type and pop result to popscope and its friend.

The use cases are to be able to capture the result when the pop is called.

migration guide: https://github.com/flutter/website/pull/9872
2024-04-18 22:36:26 +00:00
chunhtai
7ee05a05ff
Add generic type for result in PopScope (#139164)
Adds a generic type and pop result to popscope and its friend.

The use cases are to be able to capture the result when the pop is called.

migration guide: https://github.com/flutter/website/pull/9872
2024-04-18 19:30:10 +00:00
Loïc Sharma
86135b7774
[macOS] Migrate @NSApplicationMain attribute to @main (#146848)
This migrates Flutter to use the `@main` attribute introduced in Swift 5.3. The `@NSApplicationMain` attribute is deprecated and will be removed in Swift 6. See: https://github.com/apple/swift-evolution/blob/main/proposals/0383-deprecate-uiapplicationmain-and-nsapplicationmain.md

This change is split into two commits:

1. a508d3e503 - This updates the macOS app template and adds a migration to replace `@NSApplicationMain` uses with `@main`. 
2. f43482786e - I ran `flutter run -d macos` on each Flutter macOS app in this repository to verify the app migrates and launches successfully.

Follow-up to https://github.com/flutter/flutter/pull/146707
Fixes https://github.com/flutter/flutter/issues/143044
2024-04-18 03:08:36 +00:00
Michael Goderbauer
63f917c36d
Bump meta to 1.14.0 (#146925)
Not sure why the auto-roller hasn't picked this up...
2024-04-17 15:25:51 -07:00
Derek Xu
cf26b1150f
Unpin frontend_server_client and roll packages (#146650) 2024-04-17 12:43:20 -04:00
Loïc Sharma
194fefaa53
[iOS] Migrate @UIApplicationMain attribute to @main (#146707)
This migrates Flutter to use the `@main` attribute introduced in Swift 5.3. The `@UIApplicationMain` attribute is deprecated and will be removed in Swift 6. See: https://github.com/apple/swift-evolution/blob/main/proposals/0383-deprecate-uiapplicationmain-and-nsapplicationmain.md

This change is split into two commits:

1. ad18797428 - This updates the iOS app template and adds a migration to replace `@UIApplicationMain` uses with `@main`. 
2. 8ecbb2f29f - I ran `flutter run` on each Flutter iOS app in this repository to verify the app migrates and launches successfully.

Part of https://github.com/flutter/flutter/issues/143044
2024-04-16 22:13:03 +00:00
Matt Carroll
4daad32a01
Added missing tests for OverflowBar example. (#146780)
Added missing tests for OverflowBar example. Issue #130459
2024-04-16 22:10:56 +00:00
flutter-pub-roller-bot
4efdf190a8
Roll pub packages (#146842)
This PR was generated by `flutter update-packages --force-upgrade`.
2024-04-16 22:07:27 +00:00
flutter-pub-roller-bot
c06faf49e1
Roll pub packages (#146797)
This PR was generated by `flutter update-packages --force-upgrade`.
2024-04-16 06:44:25 +00:00
Christopher Fujino
7a30d2b4ca
[flutter_tools] Fix conductor for package args roll (#146646)
The interface for `ArgResults` from `package:args` has added new fields. Change the implementations of these in the conductor to extend `Fake` so that these aren't analyzer errors.

This broke the pub roll here: https://github.com/flutter/flutter/pull/146642#issuecomment-2050169629
2024-04-12 21:38:03 +00:00
Chris Bracken
a34086a573
[Windows] Drop support for Windows 7/8 apps in template (#146668)
Since Flutter no longer supports Windows 7.x or 8.x, this eliminates support from the Windows app template. No tests to eliminate, since Windows 7 and 8 were "best-efforts" tier and untested.

Fixes: https://github.com/flutter/flutter/issues/140830
RFC: http://flutter.dev/go/flutter-drop-win7-2024
2024-04-12 01:07:20 +00:00
flutter-pub-roller-bot
84c7298ba1
Roll pub packages (#146444)
This PR was generated by `flutter update-packages --force-upgrade`.
2024-04-08 18:48:19 +00:00
Taha Tesser
cba689cbf8
Add a custom shape example for AppBar.shape (#146421)
fixes [AppBar shape disappears on AppBar elevation change when scrolling](https://github.com/flutter/flutter/issues/145945)

### Description
This PR adds an example for complete custom app bar for the  `AppBar.shape` property.

### Preview

![Screenshot 2024-04-08 at 14 21 04](https://github.com/flutter/flutter/assets/48603081/ae3eda2b-b709-4652-9f2c-dd7b7dcfeb5c)
2024-04-08 18:42:07 +00:00
Kostia Sokolovskyi
8101f13a35
Add tests for theme_extension.1.dart API example. (#145819)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds tests for `examples/api/lib/material/theme/theme_extension.1.dart`
2024-04-03 23:39:17 +00:00
Taha Tesser
80d774d8dc
Add DropdownMenu cursor behavior sample (#146133)
fixes [Add `DropdownMenu` cursor behavior sample to  `DropdownMenu.enabled` & `DropdownMenu.requestFocusOnTap`  docs](https://github.com/flutter/flutter/issues/146131)

### Preview
![Screenshot 2024-04-02 at 17 12 43](https://github.com/flutter/flutter/assets/48603081/33865ca0-d48d-4651-9c83-9bdcd6369cb8)
2024-04-03 16:31:06 +00:00
Ian Hickson
950ec1c405
Enhance ColorScheme.fromSeed with a new variant parameter (#144805)
Fixes #144649

This PR is to add an enhancement for `ColorScheme.fromSeed()`.  When we input a brighter color with a high chroma and we want the resulting `ColorScheme` respects the source color, we can achieve this by setting

```dart
ColorScheme.fromSeed(
  seedColor: sourceColor,
  variant: Variant.fidelity,
  ...
)
```

Here is a demo for `ColorScheme` constructed by all 9 variants:
![Screenshot 2024-03-13 at 4 33 02 PM](https://github.com/flutter/flutter/assets/36861262/2cdbe559-67ff-4f8b-bd48-ccff5131b949)
![Screenshot 2024-03-13 at 4 33 07 PM](https://github.com/flutter/flutter/assets/36861262/e6af2362-c501-499b-8880-06a321de91e6)
2024-04-03 15:54:34 +00:00
Kostia Sokolovskyi
e6f078fff5
Add tests for material_state_mouse_cursor.0.dart API example. (#145987)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Updates `examples/api/lib/material/material_state/material_state_mouse_cursor.0.dart` to allow enable/disable `ListTile` in tests;
- Adds tests for `examples/api/lib/material/material_state/material_state_mouse_cursor.0.dart`.
2024-04-03 02:39:46 +00:00
Qun Cheng
69db714fbb
Update material_color_utilities package version to latest 0.11.1 (#145959)
This PR is to update material_color_utilities package version to the latest. `material_color_utilities/scheme/scheme_fruit_salad.dart` and `material_color_utilities/scheme/scheme_rainbow.dart` are exported after version 0.9.0.

Once this PR is merged, we don't need to explicitly import these two files like the change in PR #144805, which breaks some dependencies in `Google testing`.
2024-04-03 02:16:13 +00:00
Renzo Olivares
2a37c6f307
Implement SelectionArea triple click gestures (#144563)
This change adds support for triple click to select a paragraph at the clicked position and triple click + drag to extend the selection paragraph-by-paragraph when using the SelectionArea widget.

This PR also:
* Makes `Text` widgets a `SelectionContainer` if a parent `SelectionRegistrar` exists.
* Fixes issues with selectable ordering involving `WidgetSpan`s.

Fixes: https://github.com/flutter/flutter/issues/104552
2024-04-02 21:10:52 +00:00
Kostia Sokolovskyi
5850651d60
Add test for animated_container.0.dart API example. (#145995)
This PR contributes to https://github.com/flutter/flutter/issues/130459

### Description
- Adds test for `examples/api/test/widgets/implicit_animations/animated_container.0_test.dart`
2024-04-01 20:25:40 +00:00
Polina Cherkasova
bca1d6ad1f
Upgrade leak_tracker. (#145997) 2024-03-29 12:31:52 -07:00
Polina Cherkasova
1a2f34ab5b
Upgrade leak_tracker. (#145940) 2024-03-29 02:39:17 +00:00
Renzo Olivares
f5b65bad0f
Remove deprecated TextTheme members (#139255)
Part of: https://github.com/flutter/flutter/issues/143956
2024-03-28 01:20:55 +00:00
Taha Tesser
23687c5260
Add AnimationStyle to showBottomSheet and showModalBottomSheet (#145536)
fixes [Introduce animation customizable with `AnimationStyle` to `BottomSheet`](https://github.com/flutter/flutter/issues/145532)

### Default bottom sheet animation
![00-ezgif com-video-to-gif-converter](https://github.com/flutter/flutter/assets/48603081/a295b002-b310-4dea-8bc4-23b1d299748c)

### Custom bottom sheet animation
![01-ezgif com-video-to-gif-converter](https://github.com/flutter/flutter/assets/48603081/8c5c3d5f-e67d-4ed5-880d-f17d262087e1)

### No bottom sheet animation
![02-ezgif com-video-to-gif-converter](https://github.com/flutter/flutter/assets/48603081/872409d8-8a8d-4db9-b95b-7f96a62cdffc)
2024-03-25 08:39:05 +00:00
LongCatIsLooong
d755bc222b
Replace RenderBox.compute* with RenderBox.get* and add @visibleForOverriding (#145503)
`@visibleForOverriding` + `@protected` unfortunately does not catch the case where a `compute*` method was overridden in a subtype and the overide was called in that same type's implementation.

I did not add a `flutter_ignore` for this because it doesn't seem there will be false positives.
2024-03-22 02:44:55 +00:00
Greg Spencer
0f685f88c6
Add some cross references in the docs, move an example to a dartpad example (#145571)
## Description

This adds some "See also" links to some docs for `TweenAnimationBuilder` and `ValueListenableBuilder`.

Also, moved a "snippet" example in `ValueListenableBuilder` into the examples directory as a Dartpad example.

## Tests
 - Added test for the example.
2024-03-22 02:35:11 +00:00
Jackson Gardner
31209d04ff
flutter test --wasm support (#145347)
* Adds support for `flutter test --wasm`.
  * The test compilation flow is a bit different now, so that it supports compilers other than DDC. Specifically, when we run a set of unit tests, we generate a "switchboard" main function that imports each unit test and runs the main function for a specific one based off of a value set by the JS bootstrapping code. This way, there is one compile step and the same compile output is invoked for each unit test file.
* Also, removes all references to `dart:html` from flutter/flutter.
* Adds CI steps for running the framework unit tests with dart2wasm+skwasm
  * These steps are marked as `bringup: true`, so we don't know what kind of failures they will result in. Any failures they have will not block the tree at all yet while we're still in `bringup: true`. Once this PR is merged, I plan on looking at any failures and either fixing them or disabling them so we can get these CI steps running on presubmit.

This fixes https://github.com/flutter/flutter/issues/126692
2024-03-21 20:08:07 +00:00
flutter-pub-roller-bot
61b3f975a0
Roll pub packages (#145476)
This PR was generated by `flutter update-packages --force-upgrade`.
2024-03-21 00:09:24 +00:00
Vatsal Bhesaniya
01fc13d9f9
Add helper widget parameter to InputDecoration (#145157)
This pull request introduces a new field named `helper` to the InputDecoration class. This field allows for specifying a widget containing contextual information about the InputDecorator.child's value. Unlike `helperText`, which accepts a plain string, `helper` supports widgets, enabling functionalities like tappable links for further explanation. This change aligns with the established pattern of `error`, `label`, `prefix`, and `suffix`.

fixes [#145163](https://github.com/flutter/flutter/issues/145163)
2024-03-20 20:48:05 +00:00
Mitchell Goodwin
6190c5eea1
Widget state properties (#142151)
Fixes #138270.

Moves the majority of the logic of MaterialStateProperties down to the widgets layer, then has the existing Material classes pull from the widgets versions.
2024-03-19 17:58:13 +00:00
goodmost
3236957f02
chore: fix some comments (#145397)
fix some comments
2024-03-19 17:00:24 +00:00
Loïc Sharma
8d54abfc22
Roll pub packages manually (#145170)
The automated roll failed as a test needs to be updated: https://github.com/flutter/flutter/pull/145167

Fixes: https://github.com/flutter/flutter/issues/139861
2024-03-15 14:12:22 +00:00
Nate
b9e537336f
Turning if chains into shorter switch statements (#144977)
This pull request is part of the effort to solve issue #144903.

In the past, my efforts to reduce line length involved refactoring away from switch statements, but unlike [yesterday's PR](https://github.com/flutter/flutter/pull/144905), this one is full of switch statements that make things more concise!
2024-03-13 17:16:17 +00:00
Gray Mackall
d5896d5ede
Manually roll pub packages (#145005)
Manual takeover of https://github.com/flutter/flutter/pull/145003, to include some gradle lockfile changes.
2024-03-12 19:53:57 +00:00
Elias Elfarri
46cb2d7b01
Write unit tests for API Examples of checkbox.0, checkbox.1 (#144888)
Write unit tests for API Examples of checkbox.0, checkbox.1

Part of  #130459
2024-03-12 16:25:58 +00:00
Nate
26e379e0fc
Refactoring if chains into switch statements (#144905)
Based on issue #144903, this PR aims to bring the codebase more in line with the [Flutter repo style guide](https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#avoid-using-if-chains-or--or--with-enum-values):

> #### Avoid using `if` chains or `?:` or `==` with enum values

<br>

This change unfortunately increases the total line length, but it also improves readability.
2024-03-11 23:04:57 +00:00
Polina Cherkasova
a04fe3169a
Upgrade vm_service. (#144845) 2024-03-08 17:09:07 -08:00
Michael Goderbauer
9e46c67e9a
Fix code sample failing in smoke test (#144709)
This fixes the silent failure reported in https://github.com/flutter/flutter/issues/144353. I am experimenting in https://github.com/flutter/flutter/pull/144706 with whether the failure should have been non-silent.
2024-03-06 20:51:52 +00:00
Hans Muller
52961f761f
Updated the smiley TextButton example again (#144630)
Improved the smiley image TextButton example a little. Handling the case where the `Future.delayed` object that represents the button's one second long action is superseded by a second button press that triggers a new one-second action. This does complicate the example - just a little - but it's a little more robust. In case someone copy-and-pastes the code.

The TextButton example was recently updated: https://github.com/flutter/flutter/pull/144583
2024-03-05 20:57:02 +00:00
Hans Muller
e73e7e2e56
Updated the TextButton image button example artwork (#144583)
Updated the "smiley" TextButton example with new images from Nancy Hu @google.  I also made the example a little more complicated, per the new artwork: now it displays a different image while the button's action pretends to run for a second.

https://github.com/flutter/flutter/assets/1377460/b631a484-4b4f-4e01-ad52-a877fb46ef72
2024-03-05 03:01:40 +00:00
Taha Tesser
9a838455e2
Fix showDateRangePicker is missing dartpad tag and cleanup (#144475)
fixes [`showDateRangePicker` interactive sample not loading](https://github.com/flutter/flutter/issues/144474)

### Description 

This fixes `showDateRangePicker` example not loading in Dartpad.

Similar fix was made for `showDatePicker` in https://github.com/flutter/flutter/pull/99401
2024-03-01 15:36:24 +00:00
Taha Tesser
ba719bc588
Fix CalendarDatePicker day selection shape and overlay (#144317)
fixes [`DatePickerDialog` date entry hover background and ink splash have different radius](https://github.com/flutter/flutter/issues/141350)
fixes [Ability to customize DatePicker day selection background and overlay shape](https://github.com/flutter/flutter/issues/144220)

### 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(
      home: Scaffold(
        body: Center(
          child: Builder(builder: (context) {
            return FilledButton(
              onPressed: () {
                showDatePicker(
                  context: context,
                  initialDate: DateTime.now(),
                  firstDate: DateTime.utc(2010),
                  lastDate: DateTime.utc(2030),
                );
              },
              child: const Text('Show Date picker'),
            );
          }),
        ),
      ),
    );
  }
}
```

</details>

### Material DatePicker states specs

![overlay_specs](https://github.com/flutter/flutter/assets/48603081/45ce16cf-7ee9-41e1-a4fa-327de07b78d1)

### Day selection overlay

| Before | After |
| --------------- | --------------- |
| <img src="https://github.com/flutter/flutter/assets/48603081/b529d38d-0232-494b-8bf2-55d28420a245" /> | <img src="https://github.com/flutter/flutter/assets/48603081/c4799559-a7ef-45fd-aed9-aeb386370580"  /> |

### Hover, pressed, highlight preview

| Before | After |
| --------------- | --------------- |
| <video src="https://github.com/flutter/flutter/assets/48603081/8edde82a-7f39-4482-afab-183e1bce5991" /> | <video src="https://github.com/flutter/flutter/assets/48603081/04e1502e-67a4-4b33-973d-463067d70151" /> |

### Using `DatePickerThemeData.dayShape` to customize day selection background and overlay shape

| Before | After |
| --------------- | --------------- |
| <img src="https://github.com/flutter/flutter/assets/48603081/a0c85f58-a69b-4e14-a45d-41e580ceedce"  />  | <img src="https://github.com/flutter/flutter/assets/48603081/db67cee1-d28d-4168-98b8-fd7a9cb70cda" /> | 

### Example preview

![Screenshot 2024-02-29 at 15 07 50](https://github.com/flutter/flutter/assets/48603081/3770ed5c-28bf-4d0a-9514-87e1cd2ce515)
2024-03-01 12:44:29 +00:00
Bruno Leroux
e92bca3ff5
[flutter_tools] Update external link in Android manifest template (#144302)
## Description

This PR simplifies one external link in a commented section of the Android manifest template.

## Related Issue

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

## Tests

Documentation only PR.
2024-02-29 06:47:19 +00:00
Kate Lovett
a185ff907b
Disable flaky golden file test (#144351)
Filed https://github.com/flutter/flutter/issues/144350 for follow up.
This test has become flaky and is breaking the tree.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] 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/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#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/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
[Data Driven Fixes]:
https://github.com/flutter/flutter/wiki/Data-driven-Fixes
2024-02-28 18:10:50 -06:00
Qun Cheng
0d8eafb006
Reland "Reland - Introduce tone-based surfaces and accent color add-ons - Part 2" (#144273) 2024-02-28 13:55:50 -08:00
auto-submit[bot]
2eee0b5750
Reverts "Reland - Introduce tone-based surfaces and accent color add-ons - Part 2 (#144001)" (#144262)
Reverts flutter/flutter#144001

Initiated by: Piinks

Reason for reverting: Failing goldens at the tip of tree

Original PR Author: QuncCccccc

Reviewed By: {HansMuller}

This change reverts the following previous change:
Original Description:
Reverts flutter/flutter#143973

This is a reland for #138521 with an updated g3fix(cl/605555997). Local test: cl/609608958.
2024-02-27 22:04:18 +00:00
Qun Cheng
871d59221c
Reland - Introduce tone-based surfaces and accent color add-ons - Part 2 (#144001)
Reverts flutter/flutter#143973

This is a reland for #138521 with an updated g3fix(cl/605555997). Local test: cl/609608958.
2024-02-27 20:21:14 +00:00
LongCatIsLooong
a0a854a78b
Relands "Changing TextPainter.getOffsetForCaret implementation to remove the logarithmic search (#143281)" (reverted in #143801) (#143954)
The original PR was reverted because the new caret positioning callpath triggered a skparagraph assert. The assert has been removed. Relanding the PR with no changes applied.
2024-02-23 19:20:14 +00:00
Qun Cheng
4715216c01
Revert "Introduce tone-based surfaces and accent color add-ons - Part 2" (#143973)
Reverts flutter/flutter#138521
2024-02-22 14:51:28 -08:00
auto-submit[bot]
f9b3b84d4e
Reverts "Changing TextPainter.getOffsetForCaret implementation to remove the logarithmic search (#143281)" (#143801)
Reverts flutter/flutter#143281

Initiated by: LongCatIsLooong

Reason for reverting: https://github.com/flutter/flutter/issues/143797

Original PR Author: LongCatIsLooong

Reviewed By: {justinmc, jason-simmons}

This change reverts the following previous change:
Original Description:
The behavior largely remains the same, except:

1. The EOT cursor `(textLength, downstream)` for text ending in the opposite writing direction as the paragraph is now placed at the visual end of the last line. 
  For example, in a LTR paragraph, the EOT cursor for `aA` (lowercase for LTR and uppercase for RTL) is placed to the right of the line: `aA|` (it was `a|A` before). 
  This matches the behavior of most applications that do logical order arrow key navigation instead of visual order navigation. 
  And it makes the navigation order consistent for `aA\naA`:
```
  |aA    =>  aA|  => aA|  => aA  => aA   => aA 
   aA        aA      aA     |aA     aA|     aA|     
   (1)       (2)     (3)    (4)    (5)      (6)
```
This is indeed still pretty confusing as (2) and (3), as well as (5) and (6) are hard to distinguish (when the I beam has a large width they are actually visually distinguishable -- they use the same anchor but one gets painted to the left and the other to the right. I noticed that emacs does the same). 
But logical order navigation will always be confusing in bidi text, in one way or another.

Interestingly there are 3 different behaviors I've observed in chrome:
- the chrome download dialog (which I think uses GTK text widgets but not sure which version) gives me 2 cursors when navigating bidi text, and 
- its HTML fields only show one, and presumably they place the I beam at the **trailing edge** of the character (which makes more sense for backspacing I guess). 
- On the other hand, its (new) omnibar seems to use visual order arrow navigation

Side note: we may need to update the "tap to place the caret here" logic to handle the case where the tap lands outside of the text and the text ends in the opposite writing direction. 

2. Removed the logarithmic search. The same could be done using the characters package but when glyphInfo tells you about the baseline location in the future we probably don't need the `getBoxesForRange` call. This should fix https://github.com/flutter/flutter/issues/123424.

## Internal Tests

This is going to change the image output of some internal golden tests. I'm planning to merge https://github.com/flutter/flutter/pull/143281 before this to avoid updating the same golden files twice for invalid selections.
2024-02-21 00:10:18 +00:00
LongCatIsLooong
3538e4c788
Changing TextPainter.getOffsetForCaret implementation to remove the logarithmic search (#143281)
The behavior largely remains the same, except:

1. The EOT cursor `(textLength, downstream)` for text ending in the opposite writing direction as the paragraph is now placed at the visual end of the last line. 
  For example, in a LTR paragraph, the EOT cursor for `aA` (lowercase for LTR and uppercase for RTL) is placed to the right of the line: `aA|` (it was `a|A` before). 
  This matches the behavior of most applications that do logical order arrow key navigation instead of visual order navigation. 
  And it makes the navigation order consistent for `aA\naA`:
```
  |aA    =>  aA|  => aA|  => aA  => aA   => aA 
   aA        aA      aA     |aA     aA|     aA|     
   (1)       (2)     (3)    (4)    (5)      (6)
```
This is indeed still pretty confusing as (2) and (3), as well as (5) and (6) are hard to distinguish (when the I beam has a large width they are actually visually distinguishable -- they use the same anchor but one gets painted to the left and the other to the right. I noticed that emacs does the same). 
But logical order navigation will always be confusing in bidi text, in one way or another.

Interestingly there are 3 different behaviors I've observed in chrome:
- the chrome download dialog (which I think uses GTK text widgets but not sure which version) gives me 2 cursors when navigating bidi text, and 
- its HTML fields only show one, and presumably they place the I beam at the **trailing edge** of the character (which makes more sense for backspacing I guess). 
- On the other hand, its (new) omnibar seems to use visual order arrow navigation

Side note: we may need to update the "tap to place the caret here" logic to handle the case where the tap lands outside of the text and the text ends in the opposite writing direction. 

2. Removed the logarithmic search. The same could be done using the characters package but when glyphInfo tells you about the baseline location in the future we probably don't need the `getBoxesForRange` call. This should fix https://github.com/flutter/flutter/issues/123424.

## Internal Tests

This is going to change the image output of some internal golden tests. I'm planning to merge https://github.com/flutter/flutter/pull/143281 before this to avoid updating the same golden files twice for invalid selections.
2024-02-20 20:51:06 +00:00
Qun Cheng
a2c7ed95d1
Introduce tone-based surfaces and accent color add-ons - Part 2 (#138521)
This PR is to introduce 19 new color roles and deprecate 3 color roles in `ColorScheme`.
**Tone-based surface colors** (7 colors): 
* surfaceBright
* surfaceDim
* surfaceContainer
* surfaceContainerLowest
* surfaceContainerLow
* surfaceContainerHigh
* surfaceContainerHighest

**Accent color add-ons** (12 colors):
* primary/secondary/tertiary-Fixed
* primary/secondary/tertiary-FixedDim
* onPrimary/onSecondary/onTertiary-Fixed
* onPrimary/onSecondary/onTertiary-FixedVariant

**Deprecated colors**:
* background -> replaced with surface
* onBackground -> replaced with onSurface
* surfaceVariant -> replaced with surfaceContainerHighest

Please checkout this [design doc](https://docs.google.com/document/d/1ODqivpM_6c490T4j5XIiWCDKo5YqHy78YEFqDm4S8h4/edit?usp=sharing) for more information:)

![Screenshot 2024-01-08 at 4 56 51 PM](https://github.com/flutter/flutter/assets/36861262/353cdb4c-6ba9-4435-a518-fd3f67e415f0)
2024-02-20 19:01:50 +00:00
Michael Goderbauer
3f09b23338
cleanup now-irrelevant ignores for deprecated_member_use (#143403)
Follow-up to https://github.com/flutter/flutter/pull/143347.
2024-02-14 21:08:25 +00:00
Bruno Leroux
5c88fbf0b9
Add more documentation for TextEditingController default constructor (#143452)
## Description

This PR adds more documentation for `TextEditingController(String text)` constructor and it adds one example.

https://github.com/flutter/flutter/pull/96245 was a first improvement to the documentation.
https://github.com/flutter/flutter/issues/79495 tried to hide the cursor when an invalid selection is set but it was reverted.
https://github.com/flutter/flutter/pull/123777 mitigated the issue of having a default invalid selection: it takes care of setting a proper selection when a text field is focused and its controller selection is not initialized.

I will try changing the initial selection in another PR, but It will probably break several existing tests.

## Related Issue

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

## Tests

Adds 1 test for the new example.
2024-02-14 20:10:18 +00:00
Gray Mackall
c61dc2a586
Format all kotlin according to ktlint (#143390)
Entire pr generated with [ktlint](https://github.com/pinterest/ktlint) --format. First step before enabling linting as part of presubmit for kotlin changes.
2024-02-14 17:58:18 +00:00
Taha Tesser
ccf42dde88
Introduce avatarBoxConstraints & deleteIconBoxConstraints for the chips (#143302)
fixes [Chip widget's avatar padding changing if label text is more than 1 line](https://github.com/flutter/flutter/issues/136892)

### Code sample

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

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

List<String> strings = [
  'hello good morning',
  'hello good morning hello good morning',
  'hello good morning hello good morning hello good morning'
];

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: Row(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: [
              Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  const Text(
                      'avatarBoxConstraints: null \ndeleteIconBoxConstraints: null',
                      textAlign: TextAlign.center),
                  for (String string in strings)
                    Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: RawChip(
                        label: Container(
                          width: 150,
                          color: Colors.amber,
                          child: Text(
                            string,
                            maxLines: 3,
                            overflow: TextOverflow.ellipsis,
                          ),
                        ),
                        avatar: const Icon(Icons.settings),
                        onDeleted: () {},
                      ),
                    ),
                ],
              ),
              Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  const Text(
                      'avatarBoxConstraints: BoxConstraints.tightForFinite() \ndeleteIconBoxConstraints: BoxConstraints.tightForFinite()',
                      textAlign: TextAlign.center),
                  for (String string in strings)
                    Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: RawChip(
                        avatarBoxConstraints:
                            const BoxConstraints.tightForFinite(),
                        deleteIconBoxConstraints:
                            const BoxConstraints.tightForFinite(),
                        label: Container(
                          width: 150,
                          color: Colors.amber,
                          child: Text(
                            string,
                            maxLines: 3,
                            overflow: TextOverflow.ellipsis,
                          ),
                        ),
                        avatar: const Icon(Icons.settings),
                        onDeleted: () {},
                      ),
                    ),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}

```

</details>

### Preview
![Screenshot 2024-02-12 at 14 58 35](https://github.com/flutter/flutter/assets/48603081/5724bd07-7ac7-4987-b992-fa3ab8488273)

# Example previews
![Screenshot 2024-02-12 at 22 15 14](https://github.com/flutter/flutter/assets/48603081/33af472d-3561-47d4-8d0d-e1628de1e0aa)
![Screenshot 2024-02-12 at 22 15 46](https://github.com/flutter/flutter/assets/48603081/3de78b59-5cb6-4fd8-879b-8e204aacb069)
2024-02-13 20:30:53 +00:00
Tirth
10442399fb
Introduce iconAlignment for the buttons with icon (#137348)
Adds `iconAlignment` property to `ButtonStyleButton` widget.

Fixes #89564

### Example

https://github.com/flutter/flutter/assets/13456345/1b5236c4-5c60-4915-b3c6-0a56c43f8a19
2024-02-12 17:08:20 +00:00
Polina Cherkasova
b48dfca382
Upgrade leak_tracker. (#143236) 2024-02-09 14:41:22 -08:00
Bartek Pacia
deaa600204
Reland "Update gradle lockfiles template (#140115)" (#143081)
Trying to reland #140115 which I had to revert in #142889 because [it broke the tree](https://github.com/flutter/flutter/pull/140115#issuecomment-1925774719).

In this PR I fixed the post-submit following tests:
2024-02-08 16:22:15 +00:00
Gray Mackall
120a01ccd2
Restore log dumps for gradle OOM crashes, and set a value for MaxMetaspaceSize (#143085)
Re-sets two jvmargs that were getting cleared because we set a value for `-Xmx`. Could help with https://github.com/flutter/flutter/issues/142957. Copied from comment here https://github.com/flutter/flutter/issues/142957:
>Two random things I ran into while looking into this that might help:
>
>1. Gradle has defaults for a couple of the jvmargs, and setting any one of them clears those defaults for the others (bug here https://github.com/gradle/gradle/issues/19750). This can cause the "Gradle daemon to consume more and more native memory until it crashes", though the bug typically has a different associated error. It seems worth it to re-set those defaults.
>2. There is a property we can set that will give us a heap dump on OOM ([-XX:HeapDumpOnOutOfMemoryError](https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/clopts001.html))

Mostly just a find and replace from `find . -name gradle.properties -exec sed -i '' 's/\-Xmx4G/-Xmx4G\ \-XX:MaxMetaspaceSize=2G\ \-XX:+HeapDumpOnOutOfMemoryError/g' {} \;`, with the templates and the one test that writes from a string replaced by hand. I didn't set a value for `MaxMetaspaceSize` in the template files because I want to make sure this value doesn't cause problems in ci first (changes to the templates are essentially un-revertable for those who `flutter create` while the changes exist).
2024-02-07 19:25:39 +00:00
Bruno Leroux
6a7baf573e
Fix M3 text field height + initial step for input decorator M3 test migration (#142981)
## Description

This PR main purpose is to make progress on the M3 test migration for `InputDecorator` (see https://github.com/flutter/flutter/issues/139076).

Before this PR more than 80 of the 156 tests defined in `input_decorator_test.dart` fail on M3.
Migrating all those tests in one shot is not easy at all because many failures are related to wrong positionning due to M3 typography changes. Another reason is that several M3 specific changes are required in order to get a proper M3 compliant text field, for instance:
- https://github.com/flutter/flutter/issues/142972
- https://github.com/flutter/flutter/issues/141354

Most of the tests were relying on an helper function (`buildInputDecorator`) which had a `useMaterial3` parameter. Unfortunately when `useMaterial3: true `was passed to this function it forced `useMaterial3: false` at the top level but overrided it at a lower level, which was very misleading because people could assume that the tests are ok with M3 (but in fact they were run using M2 typography but have some M3 logic in use).
I considered various way to make this change and I finally decided to run all existing tests only on M2 for the moment. Next step will be to move most of those tests to M3. In this PR, I migrated two of these existing tests for illustration.

Because many of the existing tests are checking input decorator height, I think it would also make sense to fix https://github.com/flutter/flutter/issues/142972 first. That's why I choosed to include a fix to https://github.com/flutter/flutter/issues/142972 in this PR.

A M3 filled `TextField` on Android:

| Before this PR | After this PR |
|--------|--------|
| ![image](https://github.com/flutter/flutter/assets/840911/403225b7-4c91-4aee-b19c-0490447ae7e3) | ![image](https://github.com/flutter/flutter/assets/840911/e96cf786-a9f5-4e15-bcdd-078350ff1608) | 

## Related Issue

Fixes https://github.com/flutter/flutter/issues/142972
Related to https://github.com/flutter/flutter/issues/139076

## Tests

Updates many existing tests 
+ adds 2 tests related to the fix for https://github.com/flutter/flutter/issues/142972
+ adds 1 tests for the M3 migration
+ move 1 tests related to M3
2024-02-07 13:57:21 +00:00
Taha Tesser
c539ded64b
[reland] Add AnimationStyle to showSnackBar (#143052)
[Original was reverted due to uncaught analysis failure 
](https://github.com/flutter/flutter/pull/142825#issuecomment-1930620085)

---

fixes [`showSnackBar` is always replacing `animation` parameter of `SnackBar`](https://github.com/flutter/flutter/issues/141646)

### Code sample preview

![Screenshot 2024-02-02 at 21 10 57](https://github.com/flutter/flutter/assets/48603081/66d808f0-d638-4561-b9a4-96d1b93938f4)
2024-02-07 10:26:27 +00:00
Chris Bracken
9f8fe3f04c
[Windows] Fix signed/unsigned int comparison (#142341)
Previously, we were comparing the signed int `target_length` (returned by WideCharToMultiByte) to a size_t string length, resulting in a signed/unsigned comparison warning as follows:

```
windows\runner\utils.cpp(54,43): warning C4018:  '>': signed/unsigned mismatch
```

WideCharToMultiByte returns:
* 0 on error
* the number of bytes written to the buffer pointed to by its fifth parameter, lpMultiByteStr, on success.

As a result it's safe to store the return value in an unsigned int, which eliminates the warning.

No changes to tests since this is dependent on end-user project settings/modifications and does not trigger a warning with default project settings.

Fixes: https://github.com/flutter/flutter/issues/134227
2024-02-07 00:09:57 +00:00
auto-submit[bot]
83aca58fa7
Reverts "Add AnimationStyle to showSnackBar" (#143001)
Reverts flutter/flutter#142825

Initiated by: zanderso

Reason for reverting: Analysis failure closing the engine tree https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8756815302197889649/+/u/Framework_analyze/Framework_analyze/stdout?format=raw

Original PR Author: TahaTesser

Reviewed By: {HansMuller}

This change reverts the following previous change:
Original Description:
fixes [`showSnackBar` is always replacing `animation` parameter of `SnackBar`](https://github.com/flutter/flutter/issues/141646)

### Code sample preview

![Screenshot 2024-02-02 at 21 10 57](https://github.com/flutter/flutter/assets/48603081/66d808f0-d638-4561-b9a4-96d1b93938f4)
2024-02-06 19:35:19 +00:00
Taha Tesser
0cc381da19
Add AnimationStyle to showSnackBar (#142825)
fixes [`showSnackBar` is always replacing `animation` parameter of `SnackBar`](https://github.com/flutter/flutter/issues/141646)

### Code sample preview

![Screenshot 2024-02-02 at 21 10 57](https://github.com/flutter/flutter/assets/48603081/66d808f0-d638-4561-b9a4-96d1b93938f4)
2024-02-06 18:54:41 +00:00
auto-submit[bot]
f8a77225f3
Reverts "Update gradle lockfiles template" (#142889)
Reverts flutter/flutter#140115

Initiated by: bartekpacia

Reason for reverting: broke the tree

- [`Linux firebase_abstract_method_smoke_test`](https://ci.chromium.org/ui/p/flutter/builders/prod/Linux%20firebase_abstract_method_smoke_test/15844/overview)
- [`Linux_android android_view_scroll_perf__timeline_summary`](https://ci.chromium.org/ui/p/flutter/builders/prod/Linux_android%20android_view_scroll_perf__timeline_summary/13453/overview)
- [`Linux_android platform_views

Original PR Author: bartekpacia

Reviewed By: {gmackall}

This change reverts the following previous change:
Original Description:
This PR updates almost* all Gradle buildscripts in the Flutter repo the `example` and `dev` (in particular, in `dev/integration_tests` and in `dev/benchmarks`) directories to apply Flutter's Gradle plugins using the declarative `plugins {}` block.

*almost, because:
- add-to-app (aka hybrid) apps are not migrated (related https://github.com/flutter/flutter/issues/138756)
- apps that purposefully use build files to ensure backward compatibility (e.g. [`gradle_deprecated_settings`](https://github.com/flutter/flutter/tree/3.16.0/dev/integration_tests/gradle_deprecated_settings))
2024-02-04 14:28:18 +00:00
Bartek Pacia
85888bccf2
Update gradle lockfiles template (#140115)
This PR updates almost* all Gradle buildscripts in the Flutter repo the `example` and `dev` (in particular, in `dev/integration_tests` and in `dev/benchmarks`) directories to apply Flutter's Gradle plugins using the declarative `plugins {}` block.

*almost, because:
- add-to-app (aka hybrid) apps are not migrated (related https://github.com/flutter/flutter/issues/138756)
- apps that purposefully use build files to ensure backward compatibility (e.g. [`gradle_deprecated_settings`](https://github.com/flutter/flutter/tree/3.16.0/dev/integration_tests/gradle_deprecated_settings))
2024-02-04 13:10:49 +00:00
Hans Muller
c6f2cea65e
Reland: Added ButtonStyle.foregroundBuilder and ButtonStyle.backgroundBuilder (#142762)
Reland https://github.com/flutter/flutter/pull/141818 with a fix for a special case: If only `background` is specified for `TextButton.styleFrom` or `OutlinedButton.styleFrom` it applies the button's disabled state, i.e. as if the same value had been specified for disabledBackgroundColor.

The change relative to #141818 is the indicated line below:
```dart
final MaterialStateProperty<Color?>? backgroundColorProp = switch ((backgroundColor, disabledBackgroundColor)) {
  (null, null) => null,
  (_, null) => MaterialStatePropertyAll<Color?>(backgroundColor), // ADDED THIS LINE
  (_, _) => _TextButtonDefaultColor(backgroundColor, disabledBackgroundColor),
};
  ```

This backwards incompatibility cropped up in an internal test, see internal Google issue b/323399158.
2024-02-02 01:48:17 +00:00
Tirth
10e4f26868
Write Tests for API Example of form.0.dart (#142635)
Write Tests for API Example of `form.0.dart`.

Part of #130459
2024-02-01 21:54:46 +00:00
auto-submit[bot]
07ca92a69e
Reverts "Added ButtonStyle.foregroundBuilder and ButtonStyle.backgroundBuilder" (#142748)
Reverts flutter/flutter#141818
Initiated by: XilaiZhang
This change reverts the following previous change:
Original Description:
Fixes https://github.com/flutter/flutter/issues/139456, https://github.com/flutter/flutter/issues/130335, https://github.com/flutter/flutter/issues/89563.

Two new properties have been added to ButtonStyle to make it possible to insert arbitrary state-dependent widgets in a button's background or foreground. These properties can be specified for an individual button, using the style parameter, or for all buttons using a button theme's style parameter.

The new ButtonStyle properties are `backgroundBuilder` and `foregroundBuilder` and their (function) types are:

```dart
typedef ButtonLayerBuilder = Widget Function(
  BuildContext context,
  Set<MaterialState> states,
  Widget? child
);
```

The new builder functions are called whenever the button is built and the `states` parameter communicates the pressed/hovered/etc state fo the button.

## `backgroundBuilder`

Creates a widget that becomes the child of the button's Material and whose child is the rest of the button, including the button's `child` parameter.  By default the returned widget is clipped to the Material's ButtonStyle.shape.

The `backgroundBuilder` can be used to add a gradient to the button's background. Here's an example that creates a yellow/orange gradient background:

![opaque-gradient-bg](https://github.com/flutter/flutter/assets/1377460/80df8368-e7cf-49ef-aee7-2776a573644c)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    backgroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      return DecoratedBox(
        decoration: BoxDecoration(
          gradient: LinearGradient(colors: [Colors.orange, Colors.yellow]),
        ),
        child: child,
      );
    },
  ),
  child: Text('Text Button'),
)
```

Because the background widget becomes the child of the button's Material, if it's opaque (as it is in this case) then it obscures the overlay highlights which are painted on the button's Material. To ensure that the highlights show through one can decorate the background with an `Ink` widget.  This version also overrides the overlay color to be (shades of) red, because that makes the highlights look a little nicer with the yellow/orange background.

![ink-gradient-bg](https://github.com/flutter/flutter/assets/1377460/68a49733-f30e-44a1-a948-dc8cc95e1716)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    overlayColor: Colors.red,
    backgroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      return Ink(
        decoration: BoxDecoration(
          gradient: LinearGradient(colors: [Colors.orange, Colors.yellow]),
        ),
        child: child,
      );
    },
  ),
  child: Text('Text Button'),
)
```

Now the button's overlay highlights are painted on the Ink widget. An Ink widget isn't needed if the background is sufficiently translucent. This version of the example creates a translucent backround widget. 

![translucent-graident-bg](https://github.com/flutter/flutter/assets/1377460/3b016e1f-200a-4d07-8111-e20d29f18014)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    overlayColor: Colors.red,
    backgroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      return DecoratedBox(
        decoration: BoxDecoration(
          gradient: LinearGradient(colors: [
            Colors.orange.withOpacity(0.5),
            Colors.yellow.withOpacity(0.5),
          ]),
        ),
        child: child,
      );
    },
  ),
  child: Text('Text Button'),
)
```

One can also decorate the background with an image. In this example, the button's background is an burlap texture image. The foreground color has been changed to black to make the button's text a little clearer relative to the mottled brown backround.

![burlap-bg](https://github.com/flutter/flutter/assets/1377460/f2f61ab1-10d9-43a4-bd63-beecdce33b45)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    foregroundColor: Colors.black,
    backgroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      return Ink(
        decoration: BoxDecoration(
          image: DecorationImage(
            image: NetworkImage(burlapUrl),
            fit: BoxFit.cover,
          ),
        ),
        child: child,
      );
    },
  ),
  child: Text('Text Button'),
)
```

The background widget can depend on the `states` parameter. In this example the blue/orange gradient flips horizontally when the button is hovered/pressed.

![gradient-flip](https://github.com/flutter/flutter/assets/1377460/c6c6fe26-ae47-445b-b82d-4605d9583bd8)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    backgroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      final Color color1 = Colors.blue.withOpacity(0.5);
      final Color color2 = Colors.orange.withOpacity(0.5);
      return DecoratedBox(
        decoration: BoxDecoration(
          gradient: LinearGradient(
            colors: switch (states.contains(MaterialState.hovered)) {
              true => <Color>[color1, color2],
              false => <Color>[color2, color1],
            },
          ),
        ),
        child: child,
      );
    },
  ),
  child: Text('Text Button'),
)
```

The preceeding examples have not included a BoxDecoration border because ButtonStyle already supports `ButtonStyle.shape` and `ButtonStyle.side` parameters that can be uesd to define state-dependent borders. Borders defined with the ButtonStyle side parameter match the button's shape. To add a border that changes color when the button is hovered or pressed, one must specify the side property using `copyWith`, since there's no `styleFrom` shorthand for this case.

![border-gradient-bg](https://github.com/flutter/flutter/assets/1377460/63cffcd3-0dcf-4eb1-aed5-d14adf1e57f6)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    foregroundColor: Colors.indigo,
    backgroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      final Color color1 = Colors.blue.withOpacity(0.5);
      final Color color2 = Colors.orange.withOpacity(0.5);
      return DecoratedBox(
        decoration: BoxDecoration(
          gradient: LinearGradient(
            colors: switch (states.contains(MaterialState.hovered)) {
              true => <Color>[color1, color2],
              false => <Color>[color2, color1],
            },
          ),
        ),
        child: child,
      );
    },
  ).copyWith(
    side: MaterialStateProperty.resolveWith<BorderSide?>((Set<MaterialState> states) {
      if (states.contains(MaterialState.hovered)) {
        return BorderSide(width: 3, color: Colors.yellow);
      }
      return null; // defer to the default
    }),
  ),
  child: Text('Text Button'),
)
```

Although all of the examples have created a ButtonStyle locally and only applied it to one button, they could have configured the `ThemeData.textButtonTheme` instead and applied the style to all TextButtons. And, of course, all of this works for all of the ButtonStyleButton classes, not just TextButton.

## `foregroundBuilder`

Creates a Widget that contains the button's child parameter. The returned widget is clipped by the button's [ButtonStyle.shape] inset by the button's [ButtonStyle.padding] and aligned by the button's [ButtonStyle.alignment].

The `foregroundBuilder` can be used to wrap the button's child, e.g. with a border or a `ShaderMask` or as a state-dependent substitute for the child.

This example adds a border that's just applied to the child. The border only appears when the button is hovered/pressed.

![border-fg](https://github.com/flutter/flutter/assets/1377460/687a3245-fe68-4983-a04e-5fcc77f8aa21)

```dart
ElevatedButton(
  onPressed: () {},
  style: ElevatedButton.styleFrom(
    foregroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      final ColorScheme colorScheme = Theme.of(context).colorScheme;
      return DecoratedBox(
        decoration: BoxDecoration(
          border: states.contains(MaterialState.hovered)
            ? Border(bottom: BorderSide(color: colorScheme.primary))
            : Border(), // essentially "no border"
        ),
        child: child,
      );
    },
  ),
  child: Text('Text Button'),
)
```

The foregroundBuilder can be used with `ShaderMask` to change the way the button's child is rendered. In this example the ShaderMask's gradient causes the button's child to fade out on top.

![shader_mask_fg](https://github.com/flutter/flutter/assets/1377460/54010f24-e65d-4551-ae58-712135df3d8d)

```dart
ElevatedButton(
  onPressed: () { },
  style: ElevatedButton.styleFrom(
    foregroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      final ColorScheme colorScheme = Theme.of(context).colorScheme;
      return ShaderMask(
        shaderCallback: (Rect bounds) {
          return LinearGradient(
            begin: Alignment.bottomCenter,
            end: Alignment.topCenter,
            colors: <Color>[
              colorScheme.primary,
              colorScheme.primaryContainer,
            ],
          ).createShader(bounds);
        },
        blendMode: BlendMode.srcATop,
        child: child,
      );
    },
  ),
  child:  const Text('Elevated Button'),
)
```

A commonly requested configuration for butttons has the developer provide images, one for pressed/hovered/normal state. You can use the foregroundBuilder to create a button that fades between a normal image and another image when the button is pressed. In this case the foregroundBuilder doesn't use the child it's passed, even though we've provided the required TextButton child parameter.

![image-button](https://github.com/flutter/flutter/assets/1377460/f5b1a22f-43ce-4be3-8e70-06de4c958380)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    foregroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      final String url = states.contains(MaterialState.pressed) ? smiley2Url : smiley1Url;
      return AnimatedContainer(
        width: 100,
        height: 100,
        duration: Duration(milliseconds: 300),
        decoration: BoxDecoration(
          image: DecorationImage(
            image: NetworkImage(url),
            fit: BoxFit.contain,
          ),
        ),
      );
    },
  ),
  child: Text('No Child'),
)
```

In this example the button's default overlay appears when the button is hovered and pressed. Another image can be used to indicate the hovered state and the default overlay can be defeated by specifying `Colors.transparent` for the `overlayColor`:

![image-per-state](https://github.com/flutter/flutter/assets/1377460/7ab9da2f-f661-4374-b395-c2e0c7c4cf13)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    overlayColor: Colors.transparent,
    foregroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      String url = states.contains(MaterialState.hovered) ? smiley3Url : smiley1Url;
      if (states.contains(MaterialState.pressed)) {
        url = smiley2Url;
      }
      return AnimatedContainer(
        width: 100,
        height: 100,
        duration: Duration(milliseconds: 300),
        decoration: BoxDecoration(
          image: DecorationImage(
            image: NetworkImage(url),
            fit: BoxFit.contain,
          ),
        ),
      );
    },
  ),
  child: Text('No Child'),
)
```
2024-02-01 21:11:26 +00:00
Christopher Fujino
a80333349a
Unpin test (#141427)
Fixes https://github.com/flutter/flutter/issues/140169
2024-02-01 18:53:23 +00:00
Hans Muller
ff6c8f5d37
Added ButtonStyle.foregroundBuilder and ButtonStyle.backgroundBuilder (#141818)
Fixes https://github.com/flutter/flutter/issues/139456, https://github.com/flutter/flutter/issues/130335, https://github.com/flutter/flutter/issues/89563.

Two new properties have been added to ButtonStyle to make it possible to insert arbitrary state-dependent widgets in a button's background or foreground. These properties can be specified for an individual button, using the style parameter, or for all buttons using a button theme's style parameter.

The new ButtonStyle properties are `backgroundBuilder` and `foregroundBuilder` and their (function) types are:

```dart
typedef ButtonLayerBuilder = Widget Function(
  BuildContext context,
  Set<MaterialState> states,
  Widget? child
);
```

The new builder functions are called whenever the button is built and the `states` parameter communicates the pressed/hovered/etc state fo the button.

## `backgroundBuilder`

Creates a widget that becomes the child of the button's Material and whose child is the rest of the button, including the button's `child` parameter.  By default the returned widget is clipped to the Material's ButtonStyle.shape.

The `backgroundBuilder` can be used to add a gradient to the button's background. Here's an example that creates a yellow/orange gradient background:

![opaque-gradient-bg](https://github.com/flutter/flutter/assets/1377460/80df8368-e7cf-49ef-aee7-2776a573644c)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    backgroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      return DecoratedBox(
        decoration: BoxDecoration(
          gradient: LinearGradient(colors: [Colors.orange, Colors.yellow]),
        ),
        child: child,
      );
    },
  ),
  child: Text('Text Button'),
)
```

Because the background widget becomes the child of the button's Material, if it's opaque (as it is in this case) then it obscures the overlay highlights which are painted on the button's Material. To ensure that the highlights show through one can decorate the background with an `Ink` widget.  This version also overrides the overlay color to be (shades of) red, because that makes the highlights look a little nicer with the yellow/orange background.

![ink-gradient-bg](https://github.com/flutter/flutter/assets/1377460/68a49733-f30e-44a1-a948-dc8cc95e1716)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    overlayColor: Colors.red,
    backgroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      return Ink(
        decoration: BoxDecoration(
          gradient: LinearGradient(colors: [Colors.orange, Colors.yellow]),
        ),
        child: child,
      );
    },
  ),
  child: Text('Text Button'),
)
```

Now the button's overlay highlights are painted on the Ink widget. An Ink widget isn't needed if the background is sufficiently translucent. This version of the example creates a translucent backround widget. 

![translucent-graident-bg](https://github.com/flutter/flutter/assets/1377460/3b016e1f-200a-4d07-8111-e20d29f18014)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    overlayColor: Colors.red,
    backgroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      return DecoratedBox(
        decoration: BoxDecoration(
          gradient: LinearGradient(colors: [
            Colors.orange.withOpacity(0.5),
            Colors.yellow.withOpacity(0.5),
          ]),
        ),
        child: child,
      );
    },
  ),
  child: Text('Text Button'),
)
```

One can also decorate the background with an image. In this example, the button's background is an burlap texture image. The foreground color has been changed to black to make the button's text a little clearer relative to the mottled brown backround.

![burlap-bg](https://github.com/flutter/flutter/assets/1377460/f2f61ab1-10d9-43a4-bd63-beecdce33b45)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    foregroundColor: Colors.black,
    backgroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      return Ink(
        decoration: BoxDecoration(
          image: DecorationImage(
            image: NetworkImage(burlapUrl),
            fit: BoxFit.cover,
          ),
        ),
        child: child,
      );
    },
  ),
  child: Text('Text Button'),
)
```

The background widget can depend on the `states` parameter. In this example the blue/orange gradient flips horizontally when the button is hovered/pressed.

![gradient-flip](https://github.com/flutter/flutter/assets/1377460/c6c6fe26-ae47-445b-b82d-4605d9583bd8)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    backgroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      final Color color1 = Colors.blue.withOpacity(0.5);
      final Color color2 = Colors.orange.withOpacity(0.5);
      return DecoratedBox(
        decoration: BoxDecoration(
          gradient: LinearGradient(
            colors: switch (states.contains(MaterialState.hovered)) {
              true => <Color>[color1, color2],
              false => <Color>[color2, color1],
            },
          ),
        ),
        child: child,
      );
    },
  ),
  child: Text('Text Button'),
)
```

The preceeding examples have not included a BoxDecoration border because ButtonStyle already supports `ButtonStyle.shape` and `ButtonStyle.side` parameters that can be uesd to define state-dependent borders. Borders defined with the ButtonStyle side parameter match the button's shape. To add a border that changes color when the button is hovered or pressed, one must specify the side property using `copyWith`, since there's no `styleFrom` shorthand for this case.

![border-gradient-bg](https://github.com/flutter/flutter/assets/1377460/63cffcd3-0dcf-4eb1-aed5-d14adf1e57f6)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    foregroundColor: Colors.indigo,
    backgroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      final Color color1 = Colors.blue.withOpacity(0.5);
      final Color color2 = Colors.orange.withOpacity(0.5);
      return DecoratedBox(
        decoration: BoxDecoration(
          gradient: LinearGradient(
            colors: switch (states.contains(MaterialState.hovered)) {
              true => <Color>[color1, color2],
              false => <Color>[color2, color1],
            },
          ),
        ),
        child: child,
      );
    },
  ).copyWith(
    side: MaterialStateProperty.resolveWith<BorderSide?>((Set<MaterialState> states) {
      if (states.contains(MaterialState.hovered)) {
        return BorderSide(width: 3, color: Colors.yellow);
      }
      return null; // defer to the default
    }),
  ),
  child: Text('Text Button'),
)
```

Although all of the examples have created a ButtonStyle locally and only applied it to one button, they could have configured the `ThemeData.textButtonTheme` instead and applied the style to all TextButtons. And, of course, all of this works for all of the ButtonStyleButton classes, not just TextButton.

## `foregroundBuilder`

Creates a Widget that contains the button's child parameter. The returned widget is clipped by the button's [ButtonStyle.shape] inset by the button's [ButtonStyle.padding] and aligned by the button's [ButtonStyle.alignment].

The `foregroundBuilder` can be used to wrap the button's child, e.g. with a border or a `ShaderMask` or as a state-dependent substitute for the child.

This example adds a border that's just applied to the child. The border only appears when the button is hovered/pressed.

![border-fg](https://github.com/flutter/flutter/assets/1377460/687a3245-fe68-4983-a04e-5fcc77f8aa21)

```dart
ElevatedButton(
  onPressed: () {},
  style: ElevatedButton.styleFrom(
    foregroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      final ColorScheme colorScheme = Theme.of(context).colorScheme;
      return DecoratedBox(
        decoration: BoxDecoration(
          border: states.contains(MaterialState.hovered)
            ? Border(bottom: BorderSide(color: colorScheme.primary))
            : Border(), // essentially "no border"
        ),
        child: child,
      );
    },
  ),
  child: Text('Text Button'),
)
```

The foregroundBuilder can be used with `ShaderMask` to change the way the button's child is rendered. In this example the ShaderMask's gradient causes the button's child to fade out on top.

![shader_mask_fg](https://github.com/flutter/flutter/assets/1377460/54010f24-e65d-4551-ae58-712135df3d8d)

```dart
ElevatedButton(
  onPressed: () { },
  style: ElevatedButton.styleFrom(
    foregroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      final ColorScheme colorScheme = Theme.of(context).colorScheme;
      return ShaderMask(
        shaderCallback: (Rect bounds) {
          return LinearGradient(
            begin: Alignment.bottomCenter,
            end: Alignment.topCenter,
            colors: <Color>[
              colorScheme.primary,
              colorScheme.primaryContainer,
            ],
          ).createShader(bounds);
        },
        blendMode: BlendMode.srcATop,
        child: child,
      );
    },
  ),
  child:  const Text('Elevated Button'),
)
```

A commonly requested configuration for butttons has the developer provide images, one for pressed/hovered/normal state. You can use the foregroundBuilder to create a button that fades between a normal image and another image when the button is pressed. In this case the foregroundBuilder doesn't use the child it's passed, even though we've provided the required TextButton child parameter.

![image-button](https://github.com/flutter/flutter/assets/1377460/f5b1a22f-43ce-4be3-8e70-06de4c958380)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    foregroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      final String url = states.contains(MaterialState.pressed) ? smiley2Url : smiley1Url;
      return AnimatedContainer(
        width: 100,
        height: 100,
        duration: Duration(milliseconds: 300),
        decoration: BoxDecoration(
          image: DecorationImage(
            image: NetworkImage(url),
            fit: BoxFit.contain,
          ),
        ),
      );
    },
  ),
  child: Text('No Child'),
)
```

In this example the button's default overlay appears when the button is hovered and pressed. Another image can be used to indicate the hovered state and the default overlay can be defeated by specifying `Colors.transparent` for the `overlayColor`:

![image-per-state](https://github.com/flutter/flutter/assets/1377460/7ab9da2f-f661-4374-b395-c2e0c7c4cf13)

```dart
TextButton(
  onPressed: () {},
  style: TextButton.styleFrom(
    overlayColor: Colors.transparent,
    foregroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
      String url = states.contains(MaterialState.hovered) ? smiley3Url : smiley1Url;
      if (states.contains(MaterialState.pressed)) {
        url = smiley2Url;
      }
      return AnimatedContainer(
        width: 100,
        height: 100,
        duration: Duration(milliseconds: 300),
        decoration: BoxDecoration(
          image: DecorationImage(
            image: NetworkImage(url),
            fit: BoxFit.contain,
          ),
        ),
      );
    },
  ),
  child: Text('No Child'),
)
```
2024-02-01 00:02:23 +00:00
Zachary Anderson
6a6874ecf9
Update Android minSdkVersion to 21 (#142267)
This PR increases Android's `minSdkVersion` to 21.

There are two changes in this PR aside from simply increasing the number
from 19 to 21 everywhere.

First, tests using `flutter_gallery` fail without updating the
lockfiles. The changes in the PR are the results of running
`dev/tools/bin/generate_gradle_lockfiles.dart` on that app.

Second, from
[here](https://developer.android.com/build/multidex#mdex-pre-l):
> if your minSdkVersion is 21 or higher, multidex is enabled by default
and you don't need the multidex library.

As a result, the `multidex` option everywhere is obsolete. This PR
removes all logic and tests related to that option that I could find.
`Google testing` and `customer_tests` pass on this PR, so it seems like
this won't be too breaking if it is at all. If needed I'll give this
some time to bake in the framework before landing the flutter/engine
PRs.

Context: https://github.com/flutter/flutter/issues/138117,
https://github.com/flutter/flutter/issues/141277, b/319373605
2024-01-29 09:49:09 -08:00
LongCatIsLooong
505845c5ac
Remove textScaleFactor references from flutter/flutter (#142271)
These should the the last remaining `MediaQueryData.textScaleFactor` and `TextScaler.textScaleFactor` references.
2024-01-26 19:12:24 +00:00
Justin McCandless
204a8848a6
PopScope example improvements (#142163)
Attempting to help users understand how to build a confirmation dialog when exiting a route.
2024-01-25 10:14:49 -08:00
Polina Cherkasova
47d8252a85
Reland "Remove hack from PageView." (#142172)
Original PR: https://github.com/flutter/flutter/pull/141533
Failure: https://fusion2.corp.google.com/presubmit/601217743/OCL:601217743:BASE:601219708:1706132224874:9a4bcab3/targets
Fix: [b/321743868](https://b.corp.google.com/321743868), http://cl/601219001 (added as g3 fix.
2024-01-24 23:44:11 +00:00
Polina Cherkasova
a522b38e96
Upgrade leak_tracker. (#142162) 2024-01-24 15:33:17 -08:00
Jesús S Guerrero
a3cd05c6d3
Revert "Remove hack from PageView." (#141977)
Reverts flutter/flutter#141533

 b/321743868
2024-01-22 20:14:44 +00:00
Ian Hickson
77c3807c80
Revert "Make tests more resilient to Skia gold failures and refactor flutter_goldens for extensive technical debt removal (#140101)" (#141814)
Reverts https://github.com/flutter/flutter/pull/140101

That PR somehow made non-matching gold tests not fail at HEAD.

Fixes https://github.com/flutter/flutter/issues/141880
- Blocked by https://github.com/flutter/flutter/issues/140169
  - https://github.com/flutter/flutter/pull/141427
2024-01-19 20:29:11 +00:00
Polina Cherkasova
2cd448574b
Reland "Remove hack from PageView." (#141533)
Fixes https://github.com/flutter/flutter/issues/141119
Original PR: https://github.com/flutter/flutter/pull/141138
Revert: https://github.com/flutter/flutter/pull/141479
Reason for revert: https://fusion2.corp.google.com/presubmit/597877179/OCL:597877179:BASE:597883748:1705084754455:88d992fc/targets
Fix: cl/599347719
2024-01-18 20:45:08 +00:00
Anis Alibegić
81d80c587d
Fixed a lot of typos (#141431)
Fair amount of typos spotted and fixed. Some of them are in comments, some of them are in code and some of them are in nondart files.

There is no need for issues since it's a typo fix.

I have doubts about [packages/flutter_tools/lib/src/ios/core_devices.dart](https://github.com/flutter/flutter/compare/master...anisalibegic:flutter:master#diff-fdbc1496b4bbe7e2b445a567fd385677af861c0093774e3d8cc460fdd5b794fa), I have a feeling it might broke some things on the other end, even though it's a typo.
2024-01-12 22:10:25 +00:00
auto-submit[bot]
8f797fc379
Reverts "Remove hack from PageView." (#141479)
Reverts flutter/flutter#141138
Initiated by: itsjustkevin
This change reverts the following previous change:
Original Description:
Fixes https://github.com/flutter/flutter/issues/141119

The change is breaking, because now controller is nullable.

Migration path: https://github.com/flutter/website/pull/10033

Packages to fix:
2024-01-12 21:19:18 +00:00
Christopher Fujino
9e9af67b9a
unpin web_socket_channel and roll pub packages (#141424)
Fixes https://github.com/flutter/flutter/issues/141032

We pinned to web_socket_channel v2.4.1 because v2.4.2 was retracted, however v2.4.3 is now available.
2024-01-12 19:13:08 +00:00
Polina Cherkasova
2da87e6108
Remove hack from PageView. (#141138) 2024-01-12 09:47:34 -08:00
Mairramer
f40a99ce7e
Adds support for StepStyle visual property bundle to the Step widget (#140825)
Fixes  #140770 and #103124

Adds the possibility of passing a height and width to icons. And also a margin for the distance of the lines between the icons.
2024-01-12 16:35:08 +00:00
Qun Cheng
5887d6c742
Fix typo (#141426) 2024-01-11 17:05:01 -08:00
Taha Tesser
536de5ed91
Update RouteObserver example and fix an error thrown (#141166)
fixes [`RouteObserver` example throws an error](https://github.com/flutter/flutter/issues/141078)

### Description
This updates the `RouteObserver` example from snippet to Dartpad example and fixes the error when running the code snippet
2024-01-09 20:48:56 +00:00
Polina Cherkasova
1f3103e50d
Upgrade leak_tracker. (#141153) 2024-01-09 12:02:35 -08:00
Christopher Fujino
6edbce9e07
Manual pub roll pinning web socket channel (#141040)
Work around https://github.com/flutter/flutter/issues/141032

Otherwise a re-land of https://github.com/flutter/flutter/pull/140979

Fixes https://github.com/flutter/flutter/issues/137163 & https://github.com/flutter/flutter/issues/139181
2024-01-05 22:29:58 +00:00
auto-submit[bot]
c2286a7642
Reverts "manual pub roll to pick up dds fixes" (#141033)
Reverts flutter/flutter#140979
Initiated by: loic-sharma
This change reverts the following previous change:
Original Description:
Fixes https://github.com/flutter/flutter/issues/137163
Fixes https://github.com/flutter/flutter/issues/139181
2024-01-05 19:10:19 +00:00
Christopher Fujino
e256d49117
manual pub roll to pick up dds fixes (#140979)
Fixes https://github.com/flutter/flutter/issues/137163
Fixes https://github.com/flutter/flutter/issues/139181
2024-01-04 19:43:06 +00:00
Jenn Magder
076cb8a328
Migrate Xcode projects last version checks to Xcode 15.1 (#140256)
Change the following in the `flutter create` templates.  I didn't make any auto-migrations for existing apps because none seem that critical:
1. Turn on `ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS` in iOS and macOS.
1. Turn on `BuildIndependentTargetsInParallel` in macOS template.  https://github.com/flutter/flutter/pull/125827/files#r1181817619 
1. Turn on `DEAD_CODE_STRIPPING` in macOS template. 
1. Set `ENABLE_USER_SCRIPT_SANDBOXING=NO` in iOS and macOS template.  `flutter` scripts don't work with this on.  This might require a migration in the future to explicitly turn this one off. However at least for now if the setting isn't present it defaults to `NO`.

Add migration for `LastUpgradeVersion` so users won't see these validation issues in Xcode.

Run migrator on all the example apps.  A few aren't Flutter apps so I edited them in Xcode.

Fixes https://github.com/flutter/flutter/issues/140253
See also https://github.com/flutter/flutter/issues/125817 and https://github.com/flutter/flutter/pull/90304.
2024-01-03 23:05:46 +00:00
Furkan Acar
83ac76050d
Add SegmentedButton.styleFrom (#137542)
fixes https://github.com/flutter/flutter/issues/138289

---

SegmentedButtom.styleFrom has been added to the segment button, so there is no longer any need to the button style from the beginning. It works like ElevatedButton.styleFrom only I added selectedForegroundColor, selectedBackgroundColor. In this way, the user will be able to change the color first without checking the MaterialState states. I added tests of the same controls.

#129215 I opened this problem myself, but I was rejected because I handled too many items in a PR. For now, I wrote a structure that only handles MaterialStates instead of users.

old (still avaliable)
<img width="626" alt="image" src="https://github.com/flutter/flutter/assets/65075121/9446b13b-c355-4d20-bda2-c47a23d42d4f">

new (just an option for developer)
<img width="483" alt="image" src="https://github.com/flutter/flutter/assets/65075121/0a645257-4c83-4029-9484-bd746c02265f">

### Code sample

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

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

/// Flutter code sample for [SegmentedButton].

void main() {
  runApp(const SegmentedButtonApp());
}

enum Calendar { day, week, month, year }

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

  @override
  State<SegmentedButtonApp> createState() => _SegmentedButtonAppState();
}

class _SegmentedButtonAppState extends State<SegmentedButtonApp> {
  Calendar calendarView = Calendar.day;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(useMaterial3: true),
      home: Scaffold(
        body: Center(
          child: SegmentedButton<Calendar>(
            style: SegmentedButton.styleFrom(
              foregroundColor: Colors.amber,
              visualDensity: VisualDensity.comfortable,
            ),
            // style: const ButtonStyle(
            //   foregroundColor: MaterialStatePropertyAll<Color>(Colors.deepPurple),
            //   visualDensity: VisualDensity.comfortable,
            // ),
            segments: const <ButtonSegment<Calendar>>[
              ButtonSegment<Calendar>(
                  value: Calendar.day,
                  label: Text('Day'),
                  icon: Icon(Icons.calendar_view_day)),
              ButtonSegment<Calendar>(
                  value: Calendar.week,
                  label: Text('Week'),
                  icon: Icon(Icons.calendar_view_week)),
              ButtonSegment<Calendar>(
                  value: Calendar.month,
                  label: Text('Month'),
                  icon: Icon(Icons.calendar_view_month)),
              ButtonSegment<Calendar>(
                  value: Calendar.year,
                  label: Text('Year'),
                  icon: Icon(Icons.calendar_today)),
            ],
            selected: <Calendar>{calendarView},
            onSelectionChanged: (Set<Calendar> newSelection) {
              setState(() {
                calendarView = newSelection.first;
              });
            },
          ),
        ),
      ),
    );
  }
}

```

</details>
2024-01-03 21:26:02 +00:00
Jenn Magder
b08fc60024
Set template and migrate apps to iOS 12 minimum (#140823)
Reland https://github.com/flutter/flutter/pull/140478 with `ios_content_validation_test` test fix.
```
[ios_content_validation_test] Process terminated with exit code 0.
Task result:
{
  "success": true,
  "data": null,
  "detailFiles": [],
  "benchmarkScoreKeys": [],
  "reason": "success"
}

```

__________

1. Change templates to `IPHONEOS_DEPLOYMENT_TARGET`, `MinimumOSVersion`, and Podfile `platform :ios` to 12.0.
2. Add migrator for Podfile part to migrate `platform :ios, '11.0'` -> `platform :ios, '12.0'`
3. Compile with `-miphoneos-version-min=12.0`
4. Run the migrator on all example apps and integration tests.

See also https://github.com/flutter/flutter/pull/62902 and https://github.com/flutter/flutter/pull/85174 and https://github.com/flutter/flutter/pull/101963

Fixes https://github.com/flutter/flutter/issues/136060
2024-01-03 00:47:40 +00:00
Polina Cherkasova
45c611f040
Upgrade leak_tracker. (#140758) 2024-01-02 20:58:16 +00:00
auto-submit[bot]
bd634f3298
Reverts "Set template and migrate apps to iOS 12 minimum" (#140822)
Reverts flutter/flutter#140478
Initiated by: loic-sharma
This change reverts the following previous change:
Original Description:
1. Change templates to `IPHONEOS_DEPLOYMENT_TARGET`, `MinimumOSVersion`, and Podfile `platform :ios` to 12.0.
2. Add migrator for Podfile part to migrate `platform :ios, '11.0'` -> `platform :ios, '12.0'`
3. Compile with `-miphoneos-version-min=12.0`
4. Run the migrator on all example apps and integration tests.

See also https://github.com/flutter/flutter/pull/62902 and https://github.com/flutter/flutter/pull/85174 and https://github.com/flutter/flutter/pull/101963

Fixes https://github.com/flutter/flutter/issues/136060
2024-01-02 20:49:19 +00:00
Jenn Magder
acdbcadb9e
Set template and migrate apps to iOS 12 minimum (#140478)
1. Change templates to `IPHONEOS_DEPLOYMENT_TARGET`, `MinimumOSVersion`, and Podfile `platform :ios` to 12.0.
2. Add migrator for Podfile part to migrate `platform :ios, '11.0'` -> `platform :ios, '12.0'`
3. Compile with `-miphoneos-version-min=12.0`
4. Run the migrator on all example apps and integration tests.

See also https://github.com/flutter/flutter/pull/62902 and https://github.com/flutter/flutter/pull/85174 and https://github.com/flutter/flutter/pull/101963

Fixes https://github.com/flutter/flutter/issues/136060
2024-01-02 19:42:13 +00:00
flutter-pub-roller-bot
2d75f76b44
Roll pub packages (#140472)
This PR was generated by `flutter update-packages --force-upgrade`.
2023-12-20 22:57:21 +00:00
Polina Cherkasova
6368d65622
Upgrade to version of leak tracker that does not depend on test_widgets. (#140247)
Contributes to: https://github.com/flutter/flutter/issues/135856
2023-12-19 04:28:09 +00:00
Polina Cherkasova
bda158adf0
Reorganize dependencies on leak_tracker. (#140233)
1. Move leak_tracker and leak_tracker_testing out of direct dependencies.
2. Move leak_tracker_flutter_testing from dev to prod dependencies for flutter_test

It is prerequisite for https://github.com/flutter/flutter/issues/135856
2023-12-15 19:33:23 +00:00
Srujan Gaddam
2407f699e9
Move package:web dependency to dev dependency (#139696)
Pinning the package:web dependency constrains downstream packages from
using newer versions and making sure they support the version pinned in
Flutter. Since the usage of package:web in Flutter is light, we should
instead have a small shim like the engine and keep package:web as a dev
dependency only.
2023-12-15 08:53:27 -08:00
Polina Cherkasova
6a85684877
Increase versions of leak tracker libraries. (#140018)
Contributes to https://github.com/flutter/flutter/issues/135856
2023-12-15 05:18:23 +00:00
Nate
140f5eef4c
Implement switch expressions in examples/ and animation/ (#139882)
Thanks so much for approving the previous PR (#139048) a couple weeks ago!

This one is the same, except it's covering files in `examples/` and `packages/flutter/lib/src/animation/`.

(solving issue #136139)
2023-12-11 22:56:04 +00:00
Tirth
6a61e878a6
Renamed appbar to app_bar directory in API Examples Tests (#139922)
Tests for `app_bar.0`, `app_bar.1`, `app_bar.2`, `app_bar.3`, `sliver_app_bar.1` and `sliver_app_bar.4` were already present. But directory name was `appbar` rather than `app_bar`. I've renamed the directory to `app_bar` since example files uses that only.

Part of #130459
2023-12-11 22:54:13 +00:00
Greg Spencer
a33dec1a27
Deprecate RawKeyEvent, RawKeyboard, et al. (#136677)
## Description

This starts the deprecation of the `RawKeyEvent`/`RawKeyboard` event system that has been replaced by the `KeyEvent`/`HardwareKeyboard` event system.

Migration guide is available here: https://docs.flutter.dev/release/breaking-changes/key-event-migration

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

## Related PRs
 - https://github.com/flutter/website/pull/9889
2023-12-11 22:19:18 +00:00
Renzo Olivares
f60e54b24c
Fix SelectionArea select-word edge cases (#136920)
This change fixes issues with screen order comparison logic when rects are encompassed within each other. This was causing issues when trying to select text that includes inline `WidgetSpan`s inside of a `SelectionArea`.

* Adds `boundingBoxes` to `Selectable` for a more precise hit testing region.

Fixes #132821
Fixes updating selection edge by word boundary when widget spans are involved.
Fixes crash when sending select word selection event to an unselectable element.
2023-12-11 21:32:55 +00:00
Ian Hickson
c674161404
Animate TextStyle.fontVariations (#138881)
Fixes https://github.com/flutter/flutter/issues/105120

I also exposed the relevant dart:ui types which had the effect of removing a large number of dart:ui imports from examples.
2023-12-08 09:08:26 +00:00
Jasper van Riet
3c422dd750
Introduce exitDuration to Tooltip for mouse pointer devices (#138321)
This PR introduces a new property `exitDuration` to Tooltip, the counterpart to `waitDuration`. The need for this is shown by #136586. This changes the behaviour of `showDuration` on mouse pointer devices. This is because the use cases for the current behaviour on touch screen devices vs mouse pointer devices is fundamentally different.

<details>
<summary>Demo: tooltip with showDuration set</summary>

Tooltip disappears after 100 ms when moving away the mouse. Tooltip will not disappear when hovered.

https://github.com/flutter/flutter/assets/5138348/81d36dc9-78e0-4723-a84b-2552843ee181

</details>

Currently, when `showDuration` is set, this adjusts the time it takes for the tooltip to hide _after_ a mouse pointer has left the tooltip. This is not the same use case as its effect on touch screen devices, where it dictates how long the tooltip stays on screen after a long press. That is needed because the tooltip takes up screen space and there is not an intuitive way to hide it, whereas when using a mouse users expect to simply have to hover somewhere else. Having the tooltip stay around will look broken.

Thus, this PR splits the two use cases. `showDuration` no longer affects mouse pointer devices at all*. There is a precedent for such mouse pointer-only behaviour in `waitDuration`. Instead, I have split up the two use cases and created the new property `exitDuration`, which will still allow for tweaking the time it takes for the tooltip to hide after the user has moved their mouse pointer somewhere else.

*Note: Should `showDuration` affect [this line](e33d4b8627/packages/flutter/lib/src/material/tooltip.dart (L610))?

Fixes #136586.

Note: I noticed that when I made the change, no tests were broken. Hopefully, the tests added here help that in the future. I also noticed that in the _existing_ tests, the `waitDuration` tests contain assertions that implicate that it is the role of `waitDuration` to change this behaviour, but that's not currently (nor in the new behaviour) true, so I have fixed those tests.
2023-12-07 21:20:06 +00:00
Camille Simon
1fa54ea90a
[Android] Bump template & integration test Gradle version to 7.6.4 (#139276)
Updates Gradle version for Flutter project templates and integration tests to at least 7.6.3 (changed all of those with versions below it) to fix security vulnerability.

Part of fix for https://github.com/flutter/flutter/issues/138336.
2023-12-07 18:31:20 +00:00
Ian Hickson
fca7bc9e28
Roll dependencies (#139606)
test-exempt: rolling dependencies
2023-12-06 19:22:06 +00:00
Taha Tesser
f794cf9d97
Add AnimationStyle to ExpansionTile (#139664)
fixes [Expose animation parameters for the [ExpansionTile] widget](https://github.com/flutter/flutter/issues/138047)

### Description
Add `AnimationStyle` to the `ExpansionTile` widget to override the default expand and close animation.

Syntax:
```dart
        child: ExpansionTile(
          title: const Text('Tap to expand'),
          expansionAnimationStyle: AnimationStyle(
            duration: Durations.extralong1,
            curve: Easing.emphasizedAccelerate,
          ),
          children: const <Widget>[FlutterLogo(size: 200)],
        ),
```

### Code sample

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

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

import 'package:flutter/material.dart';

/// Flutter code sample for [ExpansionTile] and [AnimationStyle].

void main() {
  runApp(const ExpansionTileAnimationStyleApp());
}

enum AnimationStyles { defaultStyle, custom, none }
const List<(AnimationStyles, String)> animationStyleSegments = <(AnimationStyles, String)>[
  (AnimationStyles.defaultStyle, 'Default'),
  (AnimationStyles.custom, 'Custom'),
  (AnimationStyles.none, 'None'),
];

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

  @override
  State<ExpansionTileAnimationStyleApp> createState() => _ExpansionTileAnimationStyleAppState();
}

class _ExpansionTileAnimationStyleAppState extends State<ExpansionTileAnimationStyleApp> {
  Set<AnimationStyles> _animationStyleSelection = <AnimationStyles>{AnimationStyles.defaultStyle};
  AnimationStyle? _animationStyle;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              SegmentedButton<AnimationStyles>(
                selected: _animationStyleSelection,
                onSelectionChanged: (Set<AnimationStyles> styles) {
                  setState(() {
                    _animationStyleSelection = styles;
                    switch (styles.first) {
                      case AnimationStyles.defaultStyle:
                        _animationStyle = null;
                      case AnimationStyles.custom:
                        _animationStyle = AnimationStyle(
                          curve: Easing.emphasizedAccelerate,
                          duration: Durations.extralong1,
                        );
                      case AnimationStyles.none:
                        _animationStyle = AnimationStyle.noAnimation;
                    }
                  });
                },
                segments: animationStyleSegments
                  .map<ButtonSegment<AnimationStyles>>(((AnimationStyles, String) shirt) {
                    return ButtonSegment<AnimationStyles>(value: shirt.$1, label: Text(shirt.$2));
                  })
                  .toList(),
              ),
              const SizedBox(height: 20),
              ExpansionTile(
                expansionAnimationStyle: _animationStyle,
                title: const Text('ExpansionTile'),
                children: const <Widget>[
                  ListTile(title: Text('Expanded Item 1')),
                  ListTile(title: Text('Expanded Item 2')),
                ],
              )
            ],
          ),
        ),
      ),
    );
  }
}
```

</details>

Related to https://github.com/flutter/flutter/pull/138721.
2023-12-06 16:40:24 +00:00
Tirth
c10787bc6a
Write Tests for API Examples of cupertino_text_field.0, data_table.0, icon_button.2 & ink_well.0 (#139258)
Write Tests for API Examples of `cupertino_text_field.0`, `data_table.0`, `icon_button.2` & `ink_well.0`

Note: test for `cupertino_text_field.0` was already there but it was named `cupertino_text_field.0.dart`. I renamed it to `cupertino_text_field.0_test.dart`.

Part of #130459
2023-11-30 20:07:00 +00:00
Tirth
a49ee534c6
Write Tests for API Examples of snack_bar.0, elevated_button.0, stepper.0, radio.0, filled_button.0, outlined_button.0 & card.0 (#138987)
Write Tests for API Examples of `snack_bar.0`, `elevated_button.0`, `stepper.0`, `radio.0`, `filled_button.0`, `outlined_button.0` & `card.0`

Part of #130459
2023-11-28 23:57:10 +00:00
Jasper van Riet
ec639f359c
Write tests for API examples of BottomNavigationBar and IconButton (#138188)
This PR writes tests for a few of the API examples (not all), as requested in #130459. For the test names, I used the existing tests in the `api` folder as guide.
2023-11-27 17:26:37 +00:00
Taha Tesser
fc917c7184
[Reland] Introduce AnimationStyle (#138721)
This PR introduces `AnimationStyle`, it is used to override default
animation curves and durations in several widgets.

fixes [Add the ability to customize MaterialApp theme animation
duration](https://github.com/flutter/flutter/issues/78372)
fixes [Allow customization of showMenu transition animation curves and
duration](https://github.com/flutter/flutter/issues/135638)
fixes [`AnimationStyle.noAnimation` needs to replace `AnimatedTheme`
with just `Theme` in the
`MaterialApp`](https://github.com/flutter/flutter/issues/138618)

Here is an example where popup menu curve and transition duration is
overridden:

```dart
          popUpAnimationStyle: AnimationStyle(
            curve: Easing.emphasizedAccelerate,
            duration: Durations.medium4,
          ),
```

Set `AnimationStyle.noAnimation` to disable animation.
```dart
    return MaterialApp(
      themeAnimationStyle: AnimationStyle.noAnimation,
```

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] 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/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#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/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-11-20 15:24:41 -08:00
Parker Lougheed
096cdc39a9
Update links and surrounding text for new main-api docs (#138602)
Issue reference: https://github.com/flutter/flutter/issues/133877
2023-11-17 22:27:53 +00:00
auto-submit[bot]
0135a3310a
Reverts "Introduce AnimationStyle" (#138628)
Reverts flutter/flutter#137945
Initiated by: HansMuller
This change reverts the following previous change:
Original Description:
This PR introduces `AnimationStyle`, it is used to override default animation curves and durations in several widgets.

fixes  [Add the ability to customize MaterialApp theme animation duration](https://github.com/flutter/flutter/issues/78372)
fixes [Allow customization of showMenu transition animation curves and duration](https://github.com/flutter/flutter/issues/135638)

Here is an example where popup menu curve and transition duration is overriden:

```dart
          popUpAnimationStyle: AnimationStyle(
            curve: Easing.emphasizedAccelerate,
            duration: Durations.medium4,
          ),
```

Set `AnimationStyle.noAnimation` to disable animation.
```dart
    return MaterialApp(
      themeAnimationStyle: AnimationStyle.noAnimation,
```
2023-11-17 16:59:19 +00:00
Taha Tesser
19e284f88f
Introduce AnimationStyle (#137945)
This PR introduces `AnimationStyle`, it is used to override default animation curves and durations in several widgets.

fixes  [Add the ability to customize MaterialApp theme animation duration](https://github.com/flutter/flutter/issues/78372)
fixes [Allow customization of showMenu transition animation curves and duration](https://github.com/flutter/flutter/issues/135638)

Here is an example where popup menu curve and transition duration is overriden:

```dart
          popUpAnimationStyle: AnimationStyle(
            curve: Easing.emphasizedAccelerate,
            duration: Durations.medium4,
          ),
```

Set `AnimationStyle.noAnimation` to disable animation.
```dart
    return MaterialApp(
      themeAnimationStyle: AnimationStyle.noAnimation,
```
2023-11-16 18:33:20 +00:00
Bruno Leroux
dcdf72a670
[flutter_tools] - Add queries section to Android manifest file (#137207)
## Description

This PR adds a new section to the Android manifest file.
This section is required for https://github.com/flutter/engine/pull/44579 (because it uses `PackageManager.queryIntentActivities` API ), see:

1. https://developer.android.com/training/package-visibility?hl=en
2. https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT
3. https://developer.android.com/reference/android/content/pm/PackageManager?hl=en#queryIntentActivities(android.content.Intent,%20android.content.pm.PackageManager.ResolveInfoFlags)

## Related Issue

Android manifest update for https://github.com/flutter/flutter/issues/107603

## Tests

This PR updates the integration tests and examples Android manifest files, this will help catch error or warning related to this change.
2023-11-16 08:57:20 +00:00
Srujan Gaddam
d8ffc7390c
Pin package:web 0.4.0 (#138428)
This version is needed so that dart:js_interop can move to extension
types. Also adds some code to handle some breaking changes:

- Body -> Response. Body was an IDL interface mixin type we exposed in
dart:html. Going forward, users should either use Request or Response.
- Casts to JSAny. These are temporary until we move package:web types to
extension types. Currently, package:web types can't implement JSObject
as JSObject will move to be an extension type itself.

Co-authored-by: Kevin Moore <kevmoo@users.noreply.github.com>
2023-11-15 15:03:21 -08:00
huycozy
61c007a3f7
Update DraggableScrollableSheet docs to reflect API change (#136471)
### Description

This PR intends to update `DraggableScrollableSheet` docs for Web and Desktop platforms. On these platforms, the vertical dragging gesture does not provide natural behavior similar to other desktop applications. 

By adding a note before the sample code so users are aware that the sample code will not work as expected on Desktop and Web. Also, refer to the instructions if they still want to implement it on these platforms.

### Related issue

Fixes https://github.com/flutter/flutter/issues/111372
2023-11-13 21:48:03 +00:00
Polina Cherkasova
793827d98a
Upgrade leak tracker. (#138283) 2023-11-13 09:47:55 -08:00
Chinmoy
0bde95dc06
Deprecates onWillAccept and onAccept callbacks in DragTarget. (#133691)
This PR deprecates `onWillAccept` and `onAccept` over `onWillAcceptWithDetails` and `onAcceptWithDetails`.

Fixes: #133347
2023-11-10 22:47:22 +00:00
Camille Simon
c66bb0a18a
[Android] Support Android 34 (take 2) (#137967)
Re-lands https://github.com/flutter/flutter/pull/137191.

The fix for the issue causing that PR to be reverted was tested in this PR but ultimately landed separately in https://github.com/flutter/flutter/pull/138093.
2023-11-09 22:40:15 +00:00
Hans Muller
84bfe64023
Added an AnimationController API doc example (#137975)
This example shows how to use `AnimationController` and
`SlideTransition` to create an animated digit like you might find on a
digital clock. New digit values slide into place from below, as the old
value slides upwards and out of view. Taps that occur while the
controller is already animating cause the controller's
`AnimationController.duration` to be reduced so that the visuals don't
fall behind.

You can try the example here:
https://dartpad.dev/?id=9553c20fe0fdb0c5447c1293e02400eb
2023-11-07 13:33:20 -08:00
Qun Cheng
ed70f4e248
Adaptive Switch (#130425)
Currently, `Switch.factory` delegates to `CupertinoSwitch` when platform
is iOS or macOS. This PR is to:
* have the factory configure the Material `Switch` for the expected look
and feel.
* introduce `Adaptation` class to customize themes for the adaptive
components.
2023-11-07 10:26:23 -08:00
Michael Goderbauer
8a0f9118ea
Remove unused generic type from BottomSheet (#137791)
Fixes https://github.com/flutter/flutter/issues/137424.

The generic type argument was unused.
2023-11-03 22:25:37 +00:00
Chris Bobbe
e7f99821cc
Tooltip docs: Recommend setting preferBelow to false in theme (#135879)
As discussed at https://github.com/flutter/flutter/pull/133007#issuecomment-1743916183, this is a docs change meant to help people in the absence of a fix for #133006, which is being closed as WONTFIX.
2023-11-03 20:18:36 +00:00
auto-submit[bot]
c4ce9479bb
Reverts "[Android] Support Android 34" (#137865)
Reverts flutter/flutter#137191
Initiated by: camsim99
This change reverts the following previous change:
Original Description:
Adds support for Android 34 in the following ways:

- Bumps integration tests compile SDK versions 33 --> 34
- Bumps template compile SDK version 33 --> 34
- Also changes deprecated `compileSdkVersion` to `compileSdk`

Part of https://github.com/flutter/flutter/issues/134220
2023-11-03 20:14:19 +00:00
Hans Muller
3479aaba75
Updated the nested navigation NavigationBar example (#137788)
Updated the NavigationBar API doc that describes
examples/api/lib/material/navigation_bar/navigation_bar.2.dart and made
some cosmetic changes to the example to improve its appearance in
Material 3. Also did a little gratuitous reformatting.

Fixes #136125
2023-11-03 10:46:09 -07:00
Polina Cherkasova
e1b420cd5b
Upgrade leak_tracker and remove some deps in allow list. (#137806) 2023-11-03 06:20:47 -07:00
Camille Simon
675fec805a
[Android] Support Android 34 (#137191)
Adds support for Android 34 in the following ways:

- Bumps integration tests compile SDK versions 33 --> 34
- Bumps template compile SDK version 33 --> 34
- Also changes deprecated `compileSdkVersion` to `compileSdk`

Part of https://github.com/flutter/flutter/issues/134220
2023-11-02 22:18:11 +00:00
Qun Cheng
4a0f261b4e
Add Card.filled and Card.outlined factory methods (#136229)
Fixes #119401

This PR is to:
* add `Card.filled` and `Card.outlined` factory methods so that we can use tokens for these two types of cards to generate default theme instead of providing hard-corded values in example.
* update card.2.dart example.
* add test file for card.2.dart example.
* fix some mismatch caused by editing the auto-generated defaults by hand in navigation_bar.dart and navigation_drawer.dart.
2023-11-01 23:29:49 +00:00
Polina Cherkasova
d50f1fa9c9
Add dependency on leak_tracker and leak_tracker_testing to flutter_test. (#137646) 2023-10-31 19:19:12 -07:00
Polina Cherkasova
bcf267359c
Move dependency on leak_tracker from dependencies to dev_dependencies in flutter_test. (#137633)
Analyzer's dependency on autosnapshotting causes issues.

Because every version of integration_test from sdk depends on leak_tracker from hosted and autosnapshotting depends on leak_tracker from path, integration_test from sdk is forbidden.
So, because autosnapshotting depends on integration_test from sdk, version solving failed.
2023-10-31 21:12:52 +00:00
Tirth
b62da79190
Fix Typos (#137292)
Fix Small Typos.
2023-10-26 23:55:38 +00:00
Polina Cherkasova
dcbb2de0ad
Add dependency on leak_tracker to flutter_test. (#137069)
Contributes to: https://github.com/flutter/flutter/issues/135856

This PR also adds transitive dependency on  web_socket_channel, crypto, typed_data. `web_socket_channel` is needed to request retaining path for not GCed objects from VM Service. Two others are needed to serve web_socket_channel.

The dependency on leak_tracker is pinned:
aea562114c/packages/flutter_tools/lib/src/commands/update_packages.dart (L40)
2023-10-25 02:45:26 +00:00
cui fliter
c5e71b3e59
fix some typos (#137144)
*Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.*

fix some typos

*List which issues are fixed by this PR. You must list at least one issue.*

*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-10-24 15:27:07 +00:00
flutter-pub-roller-bot
d7c82888c3
Roll pub packages (#136924)
This PR was generated by `flutter update-packages --force-upgrade`.
2023-10-20 20:36:29 +00:00
Elliott Brooks
01eef7ca13
Upgrade Flutter deps to pull in latest vm_service and dwds (#136734)
Generated by running `flutter update-packages --force-upgrade`

Updates vm_service to [12.0.0](https://pub.dev/packages/vm_service/versions/12.0.0) and dwds to [22.0.0](https://pub.dev/packages/dwds/versions/22.0.0)

The changes to `packages/flutter_tools/lib/src/isolated/devfs_web.dart` are for the new interface of DWDS introduced in https://github.com/dart-lang/webdev/pull/2243

FYI @bkonyi
2023-10-19 18:29:02 +00:00
Greg Spencer
13a0d475f5
Convert menus to use OverlayPortal (#130534)
## Description

This converts the `MenuAnchor` class to use `OverlayPortal` instead of directly using the overlay.

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

## Tests
 - No tests yet (hence it is a draft)
2023-10-18 20:13:08 +00:00
Gildásio Filho
492b6f7ddf
Add findChildIndexCallback examples (#133469)
The documentation for using `findChildIndexCallback` recommends using `indexOf`, but that causes [this line](05259ca938/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart (L259)) to throw in debug mode, and when using `SliverList`, it breaks the render.

This PR changes the usage to check if the index is not negative before using it, and changes to return `null` instead if the child wasn't able to be found.

There's the related issue #107123, but this doesn't actually fix it.

-----

This PR has been updated to add the snippets that were used in the `findChildIndexCallback` comment as examples with proper tests, as well as updating the comment to reference the new examples.
2023-10-18 00:26:17 +00:00
Greg Spencer
3ef32f0407
Change some usage of RawKeyEvent to KeyEvent in preparation for deprecation (#136420)
## Description

This converts some usages of `RawKeyEvent` to `KeyEvent` to prepare the repo for deprecation of `RawKeyEvent`, and swaps out the `raw_keyboard.dart` manual test for `hardware_keyboard.dart`.

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

## Tests
 - Just refactoring code, no semantic changes.
2023-10-14 00:25:18 +00:00
Greg Spencer
22b0a62a0c
Allow TapRegion to consume tap events (#136305)
## Description

In order for `MenuAnchor` menus to be able to not pass on the taps that close their menus, `TapRegion` needed a way to consume them.  This change adds a flag to the `TapRegion`, `consumeOutsideTap` that will consume taps that occur outside of the region if the flag is set (it is false by default). The same flag is added to `MenuAnchor` to allow selecting the behavior for menus.

`TapRegion` consumes the tap event by registering with the gesture arena and immediately resolving the tap as accepted if any regions in a group have `consumeOutsideTap` set to true.

This PR also deprecates `MenuAnchor.anchorTapClosesMenu`, since it is a much more limited version of the same feature that only applied to the anchor itself, and even then only applied to closing the menu, not passing along the tap.  The same functionality can now be implemented by handling a tap on the anchor widget and checking to see if the menu is open before closing it.

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

## Tests
 - Added tests for `TapRegion` to make sure taps are consumed properly.
2023-10-12 21:04:41 +00:00
Michael Goderbauer
437361321a
Bump file,process,process_runner (#136418) 2023-10-12 13:05:24 -07:00
huycozy
e8a0cf3ae8
Fix PageView API doc sample fails on Desktop and Web (#135910)
### Description

This PR aims to improve/fix the PageView API doc sample for Web and Desktop platforms. On these platforms, mouse dragging gestures do not provide natural behavior similar to other desktop applications. This PR will add navigation buttons (indicators) so users can interact with the demo.

### Related issue

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

### Demo video

https://github.com/flutter/flutter/assets/104349824/0f9c60bd-8b18-404e-b5b6-1d594604de31
2023-10-12 17:28:13 +00:00
Kevin Moore
3e60999b11
Allow latest pkg:material_color_utilities (#132445)
* Allow latest pkg:material_color_utilities
* Bump other dependencies to their latest - including pkg:web
2023-10-11 23:57:16 +00:00
Polina Cherkasova
9d9f213eed
Upgrade leak_tracker to fix flackiness. (#135760)
Fixes: https://github.com/flutter/flutter/issues/135716
leak_tracker is left pinned because future updates are going to be breaking.
2023-09-29 18:55:21 +00:00
Renzo Olivares
21ad7122a1
Implement SelectionArea single click/tap gestures (#132682)
This change collapses the selection at the clicked/tapped location on single click down for desktop platforms, and on single click/tap up for mobile platforms to match native.

This is a change from how `SelectionArea` previously worked. Before this change a single click down would clear the selection. From observing a native browser it looks like when tapping on static text the selection is not cleared but collapsed. A user can still attain the selection from static text using the `window.getSelection` API.

https://jsfiddle.net/juepasn3/11/ You can try this demo out here to observe this behavior yourself. When clicking on static text the selection will change.

This change also allows `Paragraph.selections` to return selections that are collapsed. This for testing purposes to confirm where the selection has been collapsed.

Partially fixes: #129583
2023-09-28 01:42:16 +00:00
David Iglesias
a4bc894616
[deps] Update package:web dependency. (#135174)
This PR is the result of running:

```console
$ flutter upgrade-packages --force-upgrade
```

### Issues

* Fixes https://github.com/flutter/flutter/issues/135075
* Supersedes #135081
2023-09-20 22:55:52 +00:00
Michael Goderbauer
b0a90aee17
Enable strict-inference (#135043)
Avoids that dynamic accidentally sneaks in, see https://dart.dev/tools/analysis#enabling-additional-type-checks
2023-09-20 19:59:08 +00:00
Gray Mackall
f4b5fc1803
Unpin url launcher (remake) (#134958)
More up to date version of https://github.com/flutter/flutter/pull/133786.

Fixes https://github.com/flutter/flutter/issues/111304
2023-09-20 02:43:57 +00:00
Xilai Zhang
6425a3b431
[flutter roll] Revert "LinkedText (Linkify)" (#134955)
Reverts flutter/flutter#125927

context: b/300804374

Looks like a g3 fix might involve changing the names of widget on the customer app, and I am not sure if that would be the right approach forward. Putting up a revert to be safe for now.
2023-09-18 19:49:10 +00:00
huycozy
c2b1e483dd
Improve DropdownMenu sample code for requestFocusOnTap on mobile platforms (#134867)
### Description

This PR is to improve `DropdownMenu` sample code. By default, `requestFocusOnTap` is false on mobile platforms. When users run API sample code on mobile platforms, they can not edit the text field and think it is a bug. Although it is detailed at https://api.flutter.dev/flutter/material/DropdownMenu/requestFocusOnTap.html, users often do not pay attention to it.

### Related issue

Fixes https://github.com/flutter/flutter/issues/127672
2023-09-18 08:33:14 +00:00
Justin McCandless
4db47db177
LinkedText (Linkify) (#125927)
New LinkedText widget and TextLinker class for easily adding hyperlinks to text.
2023-09-13 20:39:58 -07:00
Zachary Anderson
4d5a1d91e1
Bump gradle heap size limit in *everywhere* (#134665)
I'm seeing these in the bot reports every week. Hopefully this is all of
them, and hopefully 4GB is enough.
2023-09-13 10:36:24 -07:00
Michael Goderbauer
05733402f7
Enable private field promotion for examples (#134478)
New feature in upcoming Dart 3.2. See https://github.com/dart-lang/language/issues/2020. Feature is enabled by bumping the min SDK version to 3.2.

In these packages, no private fields were found to be promotable.

Part of https://github.com/flutter/flutter/issues/134476.
2023-09-12 18:42:01 +00:00
Chinmay Kabi
4a3ab6828a
Fix DataTable example not being scrollable (#131556) 2023-09-11 18:55:53 -05:00
xubaolin
f4707c2b3d
fix a Scrollbar example crash (#127925)
Fix a scrollbar example crash.
https://api.flutter.dev/flutter/material/Scrollbar-class.html#material.Scrollbar.1
2023-09-08 09:40:49 +00:00
Andrea Cioni
400702d1d6
Add an example for InputChip generated by user input (#130645)
New example for `InputChip` that demonstrate how to create/delete them based on user text inputs.

The sample application shows a custom text area where user can enter text. After the user has typed and hits _Enter_ the text will be replaced with an `InputChip` that contains that text. Is it possible to continue typing and add more chips in this way. All of them will be placed in a scrollable horizontal row. Also is it possible to have suggestion displayed below the text input field in case the typed text match some of the available suggestions.

Issue I'm trying to solve:

- https://github.com/flutter/flutter/issues/128247

**Code structure:**

The example app is composed of 2 main components that find places inside `MainScreen`:

 - `ChipsInput`
 - `ListView`

`ChipsInput` emulates a `TextField` where you can enter text. This text field accepts also a list of values of generic type T (`Topping` in my example), that gets rendered as `InputChip` inside the text field, before the text inserted by the user. This widgets is basically an `InputDecorator` widget that implements `TextInputClient` to get `TextEditingValue` events from the user keyboard. At the end of the input field there is another component, the `TextCursor`, that is displayed just when the user give the focus to the field and emulates the carrets that `TextField` has.

There are also some available callbacks that the user can use to capture events in the `ChipsInput` field like: `onChanged`, `onChipTapped`, `onSubmitted` and `onTextChanged`. This last callback is used to build a list of suggestion that will be placed just below the `ChipsInput` field inside the `ListView`.
2023-09-01 00:02:04 +00:00
Kate Lovett
5b6d748cb4
Fix sample code crash, add test (#133812)
Fixes https://github.com/flutter/flutter/issues/133402

On web `1 << 32` crashes, 31 is the maximum.
2023-08-31 22:56:06 +00:00
Pierrick Bouvier
792e26df95
[Windows] Add target architecture to build path (#131843)
To implement windows-arm64 support, it is needed to add architecture as a subdirectory (https://github.com/flutter/flutter/issues/129805).

In short, when performing a flutter windows build, we have:
- Before: build/windows/runner/Release/gallery.exe
- After: build/windows/x64/runner/Release/gallery.exe

This convention follows what flutter linux build does.

Addresses: https://github.com/flutter/flutter/issues/129805
Addresses: https://github.com/flutter/flutter/issues/116196

Design doc: [flutter.dev/go/windows-arm64](https://flutter.dev/go/windows-arm64)
2023-08-31 09:09:02 -07:00
Hans Muller
336d60d29c
Updated DropdownMenu example and added a test (#133592) 2023-08-30 14:33:54 -07:00
Hans Muller
4022864c65
Added DropdownMenuEntry.labelWidget (#133491) 2023-08-29 13:01:49 -07:00
Taha Tesser
d8d7e019c1
Add FAB Additional Color Mappings example (#133453)
fixes [Additional color mappings for FAB in Material 3](https://github.com/flutter/flutter/issues/130702)

### Preview
![image](https://github.com/flutter/flutter/assets/48603081/a6f9aef6-af80-41ce-8e59-50f095db047d)
2023-08-29 17:31:02 +00:00
gmilou
40af7db6bb
Add an example showing how to use a MatrixTransition. (#132874) 2023-08-25 15:09:58 -05:00
Kenzie Davisson
61d9f55665
Update flutter packages to pick up latest vm_service (#133335)
Generated by running `flutter update-packages --force-upgrade`
2023-08-25 11:03:35 -07:00
Tomasz Gucio
5c17a37b0b
Dispose overlay entries (#132826) 2023-08-25 14:35:49 +02:00
Taha Tesser
1bc791697c
Update default menu text styles for Material 3 (#131930)
Related https://github.com/flutter/flutter/issues/131676

## Description

#### Fix default input text style for `DropdownMenu`

![dropdown_input](https://github.com/flutter/flutter/assets/48603081/301f8243-155a-4b8f-84a8-5e6b7bebb3bc)

### Fix default text style for  `MenuAnchor`'s menu items (which `DropdownMenu` uses for menu items)

![dropdown_item](https://github.com/flutter/flutter/assets/48603081/6b5be81a-72fc-4705-a577-074c7a4cad8f)

###  Default  `DropdownMenu` Input text style 

![Screenshot 2023-08-04 at 16 48 28](https://github.com/flutter/flutter/assets/48603081/bcd9da98-e74d-491e-ae64-6268ae0b3893)

### Default `DropdownMenu` menu item text style

![Screenshot 2023-08-04 at 16 50 19](https://github.com/flutter/flutter/assets/48603081/9592ca43-2854-45b5-8648-203ab65d9745)

### Default `MenuAnchor` menu item text style

![Screenshot 2023-08-04 at 14 34 28](https://github.com/flutter/flutter/assets/48603081/e87e1073-05f8-4dc7-a435-d864e9cce6ab)

### Code sample

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

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

/// Flutter code sample for [DropdownMenu]s. The first dropdown menu has an outlined border.

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

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

  @override
  State<DropdownMenuExample> createState() => _DropdownMenuExampleState();
}

class _DropdownMenuExampleState extends State<DropdownMenuExample> {
  final TextEditingController colorController = TextEditingController();
  final TextEditingController iconController = TextEditingController();
  ColorLabel? selectedColor;
  IconLabel? selectedIcon;

  @override
  Widget build(BuildContext context) {
    final List<DropdownMenuEntry<ColorLabel>> colorEntries =
        <DropdownMenuEntry<ColorLabel>>[];
    for (final ColorLabel color in ColorLabel.values) {
      colorEntries.add(
        DropdownMenuEntry<ColorLabel>(
            value: color, label: color.label, enabled: color.label != 'Grey'),
      );
    }

    final List<DropdownMenuEntry<IconLabel>> iconEntries =
        <DropdownMenuEntry<IconLabel>>[];
    for (final IconLabel icon in IconLabel.values) {
      iconEntries
          .add(DropdownMenuEntry<IconLabel>(value: icon, label: icon.label));
    }

    return MaterialApp(
      theme: ThemeData(
        useMaterial3: true,
        colorSchemeSeed: Colors.green,
        // textTheme: const TextTheme(
        //   bodyLarge: TextStyle(
        //     fontWeight: FontWeight.bold,
        //     fontStyle: FontStyle.italic,
        //     decoration: TextDecoration.underline,
        //   ),
        // ),
      ),
      home: Scaffold(
        body: SafeArea(
          child: Column(
            children: <Widget>[
              const Text('DropdownMenus'),
              Padding(
                padding: const EdgeInsets.symmetric(vertical: 20),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    DropdownMenu<ColorLabel>(
                      controller: colorController,
                      label: const Text('Color'),
                      dropdownMenuEntries: colorEntries,
                      onSelected: (ColorLabel? color) {
                        setState(() {
                          selectedColor = color;
                        });
                      },
                    ),
                    const SizedBox(width: 20),
                    DropdownMenu<IconLabel>(
                      controller: iconController,
                      enableFilter: true,
                      leadingIcon: const Icon(Icons.search),
                      label: const Text('Icon'),
                      dropdownMenuEntries: iconEntries,
                      inputDecorationTheme: const InputDecorationTheme(
                        filled: true,
                        contentPadding: EdgeInsets.symmetric(vertical: 5.0),
                      ),
                      onSelected: (IconLabel? icon) {
                        setState(() {
                          selectedIcon = icon;
                        });
                      },
                    ),
                  ],
                ),
              ),
              const Text('Plain TextFields'),
              Padding(
                padding: const EdgeInsets.symmetric(vertical: 20),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    SizedBox(
                      width: 150,
                      child: TextField(
                          controller: TextEditingController(text: 'Blue'),
                          decoration: const InputDecoration(
                            suffixIcon: Icon(Icons.arrow_drop_down),
                            labelText: 'Color',
                            border: OutlineInputBorder(),
                          )),
                    ),
                    const SizedBox(width: 20),
                    SizedBox(
                      width: 150,
                      child: TextField(
                          controller: TextEditingController(text: 'Smile'),
                          decoration: const InputDecoration(
                            prefixIcon: Icon(Icons.search),
                            suffixIcon: Icon(Icons.arrow_drop_down),
                            filled: true,
                            labelText: 'Icon',
                          )),
                    ),
                  ],
                ),
              ),
              if (selectedColor != null && selectedIcon != null)
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Text(
                        'You selected a ${selectedColor?.label} ${selectedIcon?.label}'),
                    Padding(
                      padding: const EdgeInsets.symmetric(horizontal: 5),
                      child: Icon(
                        selectedIcon?.icon,
                        color: selectedColor?.color,
                      ),
                    )
                  ],
                )
              else
                const Text('Please select a color and an icon.')
            ],
          ),
        ),
      ),
    );
  }
}

enum ColorLabel {
  blue('Blue', Colors.blue),
  pink('Pink', Colors.pink),
  green('Green', Colors.green),
  yellow('Yellow', Colors.yellow),
  grey('Grey', Colors.grey);

  const ColorLabel(this.label, this.color);
  final String label;
  final Color color;
}

enum IconLabel {
  smile('Smile', Icons.sentiment_satisfied_outlined),
  cloud(
    'Cloud',
    Icons.cloud_outlined,
  ),
  brush('Brush', Icons.brush_outlined),
  heart('Heart', Icons.favorite);

  const IconLabel(this.label, this.icon);
  final String label;
  final IconData icon;
}

``` 
	
</details>
2023-08-22 22:21:00 +00:00
Taha Tesser
af79b4c7a3
Update ExpansionPanel example for the updated expansionCallback callback (#132837)
fixes [ExpansionPanelList can't expand/collapse on the latest stable/master
](https://github.com/flutter/flutter/issues/132759)

https://github.com/flutter/flutter/pull/128082 updated the `expansionCallback` and also the `ExpansionPanel` sample in the Flutter gallery but not the API example. 

This PR fixes the API example and adds tests.
2023-08-21 20:13:22 +00:00
Justin McCandless
f68d03f1cd
Reland root predictive back (#132249)
Root predictive back (https://github.com/flutter/flutter/pull/120385) was reverted in https://github.com/flutter/flutter/pull/132167.  This PR is an attempt to reland it.

The reversion happened due to failed Google tests (b/295073110).
2023-08-17 23:55:05 +00:00
Polina Cherkasova
1a0077dc81
Upgrade flutter packages. (#132697) 2023-08-16 16:26:58 -07:00
Michael Goderbauer
14f9ed28d0
Analyze doc code snippets for all packages for which we publish docs (#132607)
Fixes TODO in the analyzer script :)
2023-08-16 22:24:48 +00:00
Polina Cherkasova
f0e7c51816
Upgrade flutter packages. (#132585) 2023-08-15 13:50:17 -07:00
Ian Hickson
ccdf826466
PaginatedDataTable improvements (#131374)
- slightly improved assert message when row cell counts don't match column count.
- more breadcrumbs in API documentation. more documentation in general.
- added more documentation for the direction of the "ascending" arrow.
- two samples for PaginatedDataTable.
- make PaginatedDataTable support hot reloading across changes to the number of columns.
- introduce matrix3MoreOrLessEquals. An earlier version of this PR used it in tests, but eventually it was not needed. The function seems useful to keep though.
2023-08-15 00:55:07 +00:00
Taha Tesser
5c96642fa0
Update menu examples for SafeArea (#132390)
fixes [Some of the menu examples don't contain `SafeArea`](https://github.com/flutter/flutter/issues/132388)

### Description

This fixes the menu examples for running on mobile with a safe area.

![Group 2](https://github.com/flutter/flutter/assets/48603081/0d460c00-60f5-45e0-87ee-c010ede9ee42)
2023-08-14 20:30:01 +00:00
Ian Hickson
4d42f1a852
GridView sample code (#131900) 2023-08-10 20:53:05 +00:00
Polina Cherkasova
60634c65b2
Upgrade flutter packages. (#132326) 2023-08-10 13:44:05 -07:00
Ian Hickson
f9a578dd82
An example of parentData usage. (#131818) 2023-08-10 19:40:06 +00:00
LongCatIsLooong
3f831b694f
Making TextPainter rounding hack disabled by default (#132094)
Migrate tests in flutter/flutter. Once the tests here and in `*_customer_testing` are migrated, the default value of the migration flag will be changed from false to true, making the rounding hack disabled by default.
2023-08-10 00:30:52 +00:00
Ian Hickson
9c8f3950e3
Sample code for ImageProvider (#131952)
Also:
- minor improvements to documentation
- wrap one of our test error messages in a manner more consistent with other messages
2023-08-09 22:58:26 +00:00
Renzo Olivares
6ac161f909
Add an example for TapAndPanGestureRecognizer (#131873)
This adds an example for `TapAndPanGestureRecognizer` that demonstrates how to scale a widget using a double tap + vertical drag gesture.

https://github.com/flutter/flutter/assets/948037/4c6c5467-2157-4b6a-bc52-264a3b6303de
2023-08-09 19:59:03 +00:00
Zachary Anderson
f4c25bbb35
Revert "Handle breaking changes in leak_tracker." (#132223)
Reverts flutter/flutter#131998

Reverting for https://github.com/flutter/flutter/issues/132222
2023-08-09 08:14:39 -07:00