Commit Graph

218 Commits

Author SHA1 Message Date
Sangam Shrestha
d261411b4c
Remove redundant useMaterial3: true (#163376)
<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

This PR removes redundant useMaterial3: true as described in
https://github.com/flutter/flutter/issues/162818

*List which issues are fixed by this PR. You must list at least one
issue. An issue is not required if the PR fixes something trivial like a
typo.*

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

## 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.
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Qun Cheng <36861262+QuncCccccc@users.noreply.github.com>
2025-03-14 17:50:20 +00:00
Ashish Beck
9af4d746df
Added semanticsIdentifier to Text Widgets (#163843)
This PR aims to add `semanticsIdentifier` to `Text` and some of its
internal objects to pass the semantics information for adding identifier
to the semantics nodes

From the issue filed at #163842, the following is a description of the
problem.

The [semantics
identifier](https://api.flutter.dev/flutter/semantics/SemanticsData/identifier.html)
helps in uniquely identifying elements using UI automation tools like
Appium, UIAutomator and XCUITests by setting identifiers that the screen
readers cannot see but the said tools can. This is especially useful
when working with a multi-lingual or multi-tenant app, where the element
IDs need to be unique but the content can be different. The `Semantics`
widget already has support for declaring it. However, the `Text` and
`Text.rich` variants only support setting `semanticsLabel` without
explicitly setting the identifiers. The widgets themselves can be
wrapped with a `Semantics` widget but it still does not cater for a rich
text that can have multiple text spans, each containing unique lables
and identifiers, and optionally gesture detectors for handling links.

Consider the following UI for two different tenants:
<img width="229" alt="Image"
src="https://github.com/user-attachments/assets/e8a24588-d94d-42fc-ba6c-ce39959207ae"
/>

Here, both the tenants utilise different strings to convey the same
message. The structure of the message stays the same so the identifiers
help in unifying the element identification process across the tenant
apps in the automation tools without having to write another script for
every other tenant.
Without the identifiers, the automation scripts require a rewrite per
tenant to be able to successfully locate the element and even tap on the
hyperlink.

# With PR Changes
## Appium Views
For the given sample code,
<details><summary>Text.rich Sample</summary>

```dart
Text.rich(
  TextSpan(
    text: 'This text contains both identifier and label.',
    semanticsLabel: 'Custom label',
    semanticsIdentifier: 'Custom identifier',
    style: customStyle1,
    children: <TextSpan>[
      TextSpan(
        text: ' While this one contains only label',
        semanticsLabel: 'Hello world',
        style: customStyle2,
      ),
      const TextSpan(
        text: ' and this contains only identifier,',
        semanticsIdentifier: 'Hello to the automation tool',
      ),
      TextSpan(
        text: ' this text contains neither identifier nor label.',
        style: customStyle2,
      ),
    ],
  ),
),
```
</details>
we have the following results with and without the PR code changes:

### With Identifier

![image](https://github.com/user-attachments/assets/abad3b36-61a5-41d9-b269-9977ac6d26e7)
### Without Identifier Changes

![image](https://github.com/user-attachments/assets/91d01be9-d39c-4c65-9251-570284108bfd)


## Semantics Tree Dump
The followings are the semantics tree dump for both the cases
<details><summary>With Identifier</summary>

```
I/flutter ( 8185): SemanticsNode#0
I/flutter ( 8185):  │ Rect.fromLTRB(0.0, 0.0, 1080.0, 2154.0)
I/flutter ( 8185):  │
I/flutter ( 8185):  └─SemanticsNode#1
I/flutter ( 8185):    │ Rect.fromLTRB(0.0, 0.0, 392.7, 783.3) scaled by 2.8x
I/flutter ( 8185):    │ textDirection: ltr
I/flutter ( 8185):    │
I/flutter ( 8185):    └─SemanticsNode#2
I/flutter ( 8185):      │ Rect.fromLTRB(0.0, 0.0, 392.7, 783.3)
I/flutter ( 8185):      │ sortKey: OrdinalSortKey#9e46a(order: 0.0)
I/flutter ( 8185):      │
I/flutter ( 8185):      └─SemanticsNode#3
I/flutter ( 8185):        │ Rect.fromLTRB(0.0, 0.0, 392.7, 783.3)
I/flutter ( 8185):        │ flags: scopesRoute
I/flutter ( 8185):        │
I/flutter ( 8185):        ├─SemanticsNode#4
I/flutter ( 8185):        │   Rect.fromLTRB(16.0, 40.0, 376.7, 88.0)
I/flutter ( 8185):        │   label: "Demonstration of automation tools support in Semantics
I/flutter ( 8185):        │     for Text and RichText"
I/flutter ( 8185):        │   textDirection: ltr
I/flutter ( 8185):        │
I/flutter ( 8185):        ├─SemanticsNode#5
I/flutter ( 8185):        │   Rect.fromLTRB(16.0, 104.0, 376.7, 204.0)
I/flutter ( 8185):        │   label: "The identifier property in Semantics widget is used for
I/flutter ( 8185):        │     UI testing with tools that work by querying the native
I/flutter ( 8185):        │     accessibility, like UIAutomator, XCUITest, or Appium. It can be
I/flutter ( 8185):        │     matched with CommonFinders.bySemanticsIdentifier."
I/flutter ( 8185):        │   textDirection: ltr
I/flutter ( 8185):        │
I/flutter ( 8185):        ├─SemanticsNode#6
I/flutter ( 8185):        │   Rect.fromLTRB(16.0, 220.0, 121.9, 244.0)
I/flutter ( 8185):        │   label: "Text Example:"
I/flutter ( 8185):        │   textDirection: ltr
I/flutter ( 8185):        │
I/flutter ( 8185):        ├─SemanticsNode#7
I/flutter ( 8185):        │   Rect.fromLTRB(16.0, 244.0, 376.7, 304.0)
I/flutter ( 8185):        │   identifier: "This is a custom identifier that only the automation
I/flutter ( 8185):        │     tools are able to see"
I/flutter ( 8185):        │   label: "This is a custom label"
I/flutter ( 8185):        │   textDirection: ltr
I/flutter ( 8185):        │
I/flutter ( 8185):        ├─SemanticsNode#8
I/flutter ( 8185):        │   Rect.fromLTRB(16.0, 320.0, 155.1, 344.0)
I/flutter ( 8185):        │   label: "Text.rich Example:"
I/flutter ( 8185):        │   textDirection: ltr
I/flutter ( 8185):        │
I/flutter ( 8185):        ├─SemanticsNode#9
I/flutter ( 8185):        │ │ Rect.fromLTRB(16.0, 344.0, 376.7, 400.0)
I/flutter ( 8185):        │ │
I/flutter ( 8185):        │ ├─SemanticsNode#10
I/flutter ( 8185):        │ │   Rect.fromLTRB(-4.0, -3.0, 280.0, 23.0)
I/flutter ( 8185):        │ │   identifier: "Custom identifier"
I/flutter ( 8185):        │ │   label: "Custom label"
I/flutter ( 8185):        │ │   textDirection: ltr
I/flutter ( 8185):        │ │   sortKey: OrdinalSortKey#06bc7(order: 0.0)
I/flutter ( 8185):        │ │
I/flutter ( 8185):        │ ├─SemanticsNode#11
I/flutter ( 8185):        │ │   Rect.fromLTRB(-4.0, -1.0, 345.0, 42.0)
I/flutter ( 8185):        │ │   label: "Hello world"
I/flutter ( 8185):        │ │   textDirection: ltr
I/flutter ( 8185):        │ │   sortKey: OrdinalSortKey#32a12(order: 1.0)
I/flutter ( 8185):        │ │
I/flutter ( 8185):        │ ├─SemanticsNode#12
I/flutter ( 8185):        │ │   Rect.fromLTRB(130.0, 17.0, 348.0, 43.0)
I/flutter ( 8185):        │ │   identifier: "Hello to the automation tool"
I/flutter ( 8185):        │ │   label: " and this contains only identifier,"
I/flutter ( 8185):        │ │   textDirection: ltr
I/flutter ( 8185):        │ │   sortKey: OrdinalSortKey#49d25(order: 2.0)
I/flutter ( 8185):        │ │
I/flutter ( 8185):        │ └─SemanticsNode#13
I/flutter ( 8185):        │     Rect.fromLTRB(-4.0, 19.0, 351.0, 60.0)
I/flutter ( 8185):        │     label: " this text contains neither identifier nor label."
I/flutter ( 8185):        │     textDirection: ltr
I/flutter ( 8185):        │     sortKey: OrdinalSortKey#f3624(order: 3.0)
I/flutter ( 8185):        │
I/flutter ( 8185):        ├─SemanticsNode#14
I/flutter ( 8185):        │   Rect.fromLTRB(16.0, 416.0, 181.0, 440.0)
I/flutter ( 8185):        │   label: "Multi-tenant Example:"
I/flutter ( 8185):        │   textDirection: ltr
I/flutter ( 8185):        │
I/flutter ( 8185):        ├─SemanticsNode#15
I/flutter ( 8185):        │ │ Rect.fromLTRB(108.3, 440.0, 284.5, 480.0)
I/flutter ( 8185):        │ │
I/flutter ( 8185):        │ ├─SemanticsNode#16
I/flutter ( 8185):        │ │   Rect.fromLTRB(-1.0, -3.0, 115.0, 23.0)
I/flutter ( 8185):        │ │   identifier: "please_open"
I/flutter ( 8185):        │ │   label: "Please open the "
I/flutter ( 8185):        │ │   textDirection: ltr
I/flutter ( 8185):        │ │   sortKey: OrdinalSortKey#ea831(order: 0.0)
I/flutter ( 8185):        │ │
I/flutter ( 8185):        │ ├─SemanticsNode#17
I/flutter ( 8185):        │ │   Rect.fromLTRB(106.0, -3.0, 177.0, 23.0)
I/flutter ( 8185):        │ │   identifier: "product_name"
I/flutter ( 8185):        │ │   label: "product 1"
I/flutter ( 8185):        │ │   textDirection: ltr
I/flutter ( 8185):        │ │   sortKey: OrdinalSortKey#589fe(order: 1.0)
I/flutter ( 8185):        │ │
I/flutter ( 8185):        │ ├─SemanticsNode#18
I/flutter ( 8185):        │ │   Rect.fromLTRB(-4.0, -3.0, 177.0, 43.0)
I/flutter ( 8185):        │ │   identifier: "to_use_app"
I/flutter ( 8185):        │ │   label:
I/flutter ( 8185):        │ │     "
I/flutter ( 8185):        │ │     to use this app."
I/flutter ( 8185):        │ │   textDirection: ltr
I/flutter ( 8185):        │ │   sortKey: OrdinalSortKey#c2762(order: 2.0)
I/flutter ( 8185):        │ │
I/flutter ( 8185):        │ └─SemanticsNode#19
I/flutter ( 8185):        │     Rect.fromLTRB(95.0, 17.0, 181.0, 43.0)
I/flutter ( 8185):        │     actions: tap
I/flutter ( 8185):        │     flags: isLink
I/flutter ( 8185):        │     identifier: "learn_more_link"
I/flutter ( 8185):        │     label: " Learn more"
I/flutter ( 8185):        │     textDirection: ltr
I/flutter ( 8185):        │     sortKey: OrdinalSortKey#7d560(order: 3.0)
I/flutter ( 8185):        │
I/flutter ( 8185):        └─SemanticsNode#20
I/flutter ( 8185):          │ Rect.fromLTRB(97.0, 496.0, 295.7, 536.0)
I/flutter ( 8185):          │
I/flutter ( 8185):          ├─SemanticsNode#21
I/flutter ( 8185):          │   Rect.fromLTRB(11.0, -3.0, 127.0, 23.0)
I/flutter ( 8185):          │   identifier: "please_open"
I/flutter ( 8185):          │   label: "Please open the "
I/flutter ( 8185):          │   textDirection: ltr
I/flutter ( 8185):          │   sortKey: OrdinalSortKey#7bb57(order: 0.0)
I/flutter ( 8185):          │
I/flutter ( 8185):          ├─SemanticsNode#22
I/flutter ( 8185):          │   Rect.fromLTRB(118.0, -3.0, 188.0, 23.0)
I/flutter ( 8185):          │   identifier: "product_name"
I/flutter ( 8185):          │   label: "product 2"
I/flutter ( 8185):          │   textDirection: ltr
I/flutter ( 8185):          │   sortKey: OrdinalSortKey#6c7c6(order: 1.0)
I/flutter ( 8185):          │
I/flutter ( 8185):          ├─SemanticsNode#23
I/flutter ( 8185):          │   Rect.fromLTRB(-4.0, -3.0, 188.0, 43.0)
I/flutter ( 8185):          │   identifier: "to_use_app"
I/flutter ( 8185):          │   label:
I/flutter ( 8185):          │     "
I/flutter ( 8185):          │     to access this app."
I/flutter ( 8185):          │   textDirection: ltr
I/flutter ( 8185):          │   sortKey: OrdinalSortKey#1e8e7(order: 2.0)
I/flutter ( 8185):          │
I/flutter ( 8185):          └─SemanticsNode#24
I/flutter ( 8185):              Rect.fromLTRB(117.0, 17.0, 203.0, 43.0)
I/flutter ( 8185):              actions: tap
I/flutter ( 8185):              flags: isLink
I/flutter ( 8185):              identifier: "learn_more_link"
I/flutter ( 8185):              label: " Find out more"
I/flutter ( 8185):              textDirection: ltr
I/flutter ( 8185):              sortKey: OrdinalSortKey#db7e6(order: 3.0)
```

</details>
<details><summary>Without Identifier Changes</summary>

```
I/flutter (18659): SemanticsNode#0
I/flutter (18659):  │ Rect.fromLTRB(0.0, 0.0, 1080.0, 2154.0)
I/flutter (18659):  │
I/flutter (18659):  └─SemanticsNode#1
I/flutter (18659):    │ Rect.fromLTRB(0.0, 0.0, 392.7, 783.3) scaled by 2.8x
I/flutter (18659):    │ textDirection: ltr
I/flutter (18659):    │
I/flutter (18659):    └─SemanticsNode#2
I/flutter (18659):      │ Rect.fromLTRB(0.0, 0.0, 392.7, 783.3)
I/flutter (18659):      │ sortKey: OrdinalSortKey#102d4(order: 0.0)
I/flutter (18659):      │
I/flutter (18659):      └─SemanticsNode#3
I/flutter (18659):        │ Rect.fromLTRB(0.0, 0.0, 392.7, 783.3)
I/flutter (18659):        │ flags: scopesRoute
I/flutter (18659):        │
I/flutter (18659):        ├─SemanticsNode#4
I/flutter (18659):        │   Rect.fromLTRB(16.0, 40.0, 376.7, 88.0)
I/flutter (18659):        │   label: "Demonstration of automation tools support in Semantics
I/flutter (18659):        │     for Text and RichText"
I/flutter (18659):        │   textDirection: ltr
I/flutter (18659):        │
I/flutter (18659):        ├─SemanticsNode#5
I/flutter (18659):        │   Rect.fromLTRB(16.0, 104.0, 376.7, 204.0)
I/flutter (18659):        │   label: "The identifier property in Semantics widget is used for
I/flutter (18659):        │     UI testing with tools that work by querying the native
I/flutter (18659):        │     accessibility, like UIAutomator, XCUITest, or Appium. It can be
I/flutter (18659):        │     matched with CommonFinders.bySemanticsIdentifier."
I/flutter (18659):        │   textDirection: ltr
I/flutter (18659):        │
I/flutter (18659):        ├─SemanticsNode#6
I/flutter (18659):        │   Rect.fromLTRB(16.0, 220.0, 121.9, 244.0)
I/flutter (18659):        │   label: "Text Example:"
I/flutter (18659):        │   textDirection: ltr
I/flutter (18659):        │
I/flutter (18659):        ├─SemanticsNode#7
I/flutter (18659):        │   Rect.fromLTRB(16.0, 244.0, 376.7, 304.0)
I/flutter (18659):        │   label: "This is a custom label"
I/flutter (18659):        │   textDirection: ltr
I/flutter (18659):        │
I/flutter (18659):        ├─SemanticsNode#8
I/flutter (18659):        │   Rect.fromLTRB(16.0, 320.0, 155.1, 344.0)
I/flutter (18659):        │   label: "Text.rich Example:"
I/flutter (18659):        │   textDirection: ltr
I/flutter (18659):        │
I/flutter (18659):        ├─SemanticsNode#9
I/flutter (18659):        │   Rect.fromLTRB(16.0, 344.0, 376.7, 400.0)
I/flutter (18659):        │   label: "Custom labelHello world and this contains only
I/flutter (18659):        │     identifier, this text contains neither identifier nor label."
I/flutter (18659):        │   textDirection: ltr
I/flutter (18659):        │
I/flutter (18659):        ├─SemanticsNode#10
I/flutter (18659):        │   Rect.fromLTRB(16.0, 416.0, 181.0, 440.0)
I/flutter (18659):        │   label: "Multi-tenant Example:"
I/flutter (18659):        │   textDirection: ltr
I/flutter (18659):        │
I/flutter (18659):        ├─SemanticsNode#11
I/flutter (18659):        │ │ Rect.fromLTRB(108.3, 456.0, 284.5, 496.0)
I/flutter (18659):        │ │
I/flutter (18659):        │ ├─SemanticsNode#12
I/flutter (18659):        │ │   Rect.fromLTRB(-4.0, -3.0, 177.0, 43.0)
I/flutter (18659):        │ │   label:
I/flutter (18659):        │ │     "Please open the product 1
I/flutter (18659):        │ │     to use this app."
I/flutter (18659):        │ │   textDirection: ltr
I/flutter (18659):        │ │   sortKey: OrdinalSortKey#493fc(order: 0.0)
I/flutter (18659):        │ │
I/flutter (18659):        │ └─SemanticsNode#13
I/flutter (18659):        │     Rect.fromLTRB(95.0, 17.0, 181.0, 43.0)
I/flutter (18659):        │     actions: tap
I/flutter (18659):        │     flags: isLink
I/flutter (18659):        │     label: " Learn more"
I/flutter (18659):        │     textDirection: ltr
I/flutter (18659):        │     sortKey: OrdinalSortKey#587bf(order: 1.0)
I/flutter (18659):        │
I/flutter (18659):        └─SemanticsNode#14
I/flutter (18659):          │ Rect.fromLTRB(88.9, 512.0, 303.8, 552.0)
I/flutter (18659):          │
I/flutter (18659):          ├─SemanticsNode#15
I/flutter (18659):          │   Rect.fromLTRB(-4.0, -3.0, 196.0, 43.0)
I/flutter (18659):          │   label:
I/flutter (18659):          │     "Please open the product 2
I/flutter (18659):          │     to access this app."
I/flutter (18659):          │   textDirection: ltr
I/flutter (18659):          │   sortKey: OrdinalSortKey#69083(order: 0.0)
I/flutter (18659):          │
I/flutter (18659):          └─SemanticsNode#16
I/flutter (18659):              Rect.fromLTRB(117.0, 17.0, 219.0, 43.0)
I/flutter (18659):              actions: tap
I/flutter (18659):              flags: isLink
I/flutter (18659):              label: " Find out more"
I/flutter (18659):              textDirection: ltr
I/flutter (18659):              sortKey: OrdinalSortKey#ed706(order: 1.0)
```

</details>


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

---------

Co-authored-by: chunhtai <47866232+chunhtai@users.noreply.github.com>
2025-03-12 23:30:16 +00:00
Hannes Hultergård
6958d086bc
Add action for configuring default action of EditableText.onTapUpOutside (#162575)
This PR adds an `Action` for configuring a default action of
`EditableText.onTapUpOutside`. This is the equivalent to what
https://github.com/flutter/flutter/pull/150125 did for
`EditableText.onTapOutside`.

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

## 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.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
2025-02-28 19:01:33 +00:00
davidhicks980
d48820528c
[raw_menu_anchor.0.dart] Remove misdrawn emojis. (#162807)
This PR removes the leading emojis displayed on the RawMenuAnchor
example. I knew emojis usually showed up monochrome on web, but code
samples also appear to incorrectly display the emoji source.

Because this change doesn't affect the menu's functionality, I didn't
include additional tests, but I'd be happy to add tests if needed. One
test was modified to account for menu items no longer having a leading
icon.

<img width="1247" alt="image"
src="https://github.com/user-attachments/assets/58a338c8-c882-4ad1-af44-596d91e9f382"
/>

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

## 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 `///`).
- [ ] 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/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Tirth <pateltirth454@gmail.com>
2025-02-07 20:45:35 +00:00
davidhicks980
b29f8f7fb9
Implement RawMenuAnchor (#158255)
This PR adds a `RawMenuAnchor()` widget to widgets.dart. The purpose of
this widget is to provide a menu primitive for the Material and
Cupertino libraries (and others) to build upon. Additionally, this PR
makes MenuController an inherited widget to simplify nested access to
the menu (e.g. if you want to launch a context menu from a deeply-nested
widget).

This PR:
* Centralizes core menu logic to a private class,` _RawMenuAnchor()`, 
  * Provides the internals for interacting with menus:
    * TapRegion interop
    * DismissMenuAction handler
    * Close on scroll/resize
    * Focus traversal information, if applicable
* Subclasses override `_open`, `_close`, `_isOpen`, `_buildAnchor`, and
`_menuScopeNode`
* State is accessible by descendents via
`MenuController.maybeOf(context)._anchor`
* Adds 2 public constructors, backed by a `_RawMenuAnchor()` that
contains shared logic.
  * `RawMenuAnchor()`
    * Users build the overlay from scratch.
* Provides anchor/overlay position information and TapRegionGroupId to
builder
    * Does not provide FocusScope management. 
  * `RawMenuAnchorGroup()`
    * A primitive for menus that do not have overlays (menu bars). 
* This was previously called RawMenuAnchor.node(), but @dkwingsmt made a
good case for splitting out the constructor.

<s>Documentation examples have been added, and can be viewed at
https://menu-anchor.web.app/</s>


<s>https://github.com/user-attachments/assets/25d35f23-2aad-4d07-9172-5c3fd65d53cf</s>

@dkwingsmt 

List which issues are fixed by this PR.
https://github.com/flutter/flutter/pull/143712

Some issues that need to be addressed:

Semantics:
<img width="1027" alt="image"
src="https://github.com/user-attachments/assets/d69661c9-8435-4d9c-b200-474968cb57eb">
I'm basing the menu semantics off of the comment
[here](ef3ca70db2/lib/web_ui/lib/src/engine/semantics/semantics.dart (L382)),
but I'm unsure whether the route should be given a name. There is no
menubar/menu/menuitem role in Flutter, so I'm assuming the menu should
be composed of nested dialogs

<s>Unlike the menubar pattern from
[W3C](https://www.w3.org/WAI/ARIA/apg/patterns/menubar/examples/menubar-navigation/),
the RawMenuAnchor

- does not close on tab/shift-tab. I left this behavior out of the menu
so that users could customize tab behavior, but I'm not opinionated
either way
- does not open on ArrowUp/ArrowDown, because this could interfere with
user focus behavior in unconventional menu setups (e.g. a vertical
menu).
- does not automatically focus the first item in a menu overlay when
activated via enter/spacebar, but does focus the first item when
horizontal traversal opens a submenu. Automatically focusing the first
item whenever an overlay opens interferes with hover traversal, and I
couldn't think of a good way to only focus the first item when an
overlay is triggered via enter/spacebar.
- doesn't focus disabled items (I wasn't sure how to address this
without editing MenuItemButton)

While it is possible to nest menus -- for example, a dropdown anchor
within a full-app context menu area -- nested menus behave as a single
group. I was considering adding an additional parameter that separates
nested root menus from their parents, and am interested to hear your
feedback.</s>

*If you had to change anything in the [flutter/tests] repo, include a
link to the migration guide as per the [breaking change policy].*

## 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/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Bruno Leroux <bruno.leroux@gmail.com>
Co-authored-by: chunhtai <47866232+chunhtai@users.noreply.github.com>
2025-02-03 23:55:03 +00:00
Michael Goderbauer
9cab4ffee1
Use wildcards (#161548)
https://dart.dev/language/pattern-types#wildcard
2025-01-14 05:13:41 +00:00
Michael Goderbauer
5491c8c146
Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.

**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
2024-12-19 20:06:21 +00:00
Tess Strickland
ddc0866e8f
Add more entry-point annotations for test-only code. (#160421)
This change adds entry-point annotations to methods and classes accessed
by native code during Flutter tests. Currently, entry point annotations
are not checked by the Dart VM when running in JIT mode, only in AOT
mode. In order to also enforce entry point annotations in JIT mode,
first tests in Flutter must be appropriately annotated to avoid roll
failures.

Related issues:
* https://github.com/flutter/flutter/issues/118608
* https://github.com/dart-lang/sdk/issues/50649

## 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/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
2024-12-17 11:40:14 +00:00
Nate Wilson
dc5809309a
Fix SafeArea DartPad sample (#159344)
This pull request fixes a bug I introduced in
https://github.com/flutter/flutter/pull/158019.

<br>

<h3 align="center">Before</h3>
<p align="center">
  <img 

src="https://github.com/user-attachments/assets/fcb68fac-9c63-445d-8d2b-afc28c685053"
    alt="RenderFlex overflowed"
    width="523px"
  />
</p>

<h3 align="center">After</h3>
<p align="center">
  <img 

src="https://github.com/user-attachments/assets/82091c6a-b3c5-4994-978e-5e76cbb7edfd"
    alt="RenderFlex overflowed"
    width="523px"
  />
</p>

<br><br>

- fixes https://github.com/flutter/flutter/issues/159340
2024-12-09 19:54:08 +00:00
Qun Cheng
92107b15fd
Create new page transition for M3 (#158881)
This PR is to add a new page transition for Material 3. 

The new builder matches the latest Android page transition behavior;
while the new page slides in from right to left, it fades in at the same
time and the old page slides out from right to left, fading out at the
same time. When both pages are fading in/out, the black background might
show up, so I added a `ColoredBox` for the slides-out page whose color
defaults to `ColorScheme.surface`. The `backgroundColor` property can be
used to customize the default transition color.

This demo shows the forward and backward behaviors.


https://github.com/user-attachments/assets/a806f25d-8564-4cad-8dfc-eb4585294181

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

## 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.
2024-12-07 00:56:57 +00:00
Anis Alibegić
e2ada1c939
Fixed typos (#159331)
Here's another one of my PRs where I hunt for typos across `flutter`
repo.

## 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].
- [ ] 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].
- [x] All existing and new tests are passing.

<!-- 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
2024-12-05 16:54:09 +00:00
Neutrino2711
4b818b56c2
Updated document to clarify Clip Behaviour (#157719)
Revised comments to clarify that clipping of child depends on clipBehavior of the parent widget, typically scrollable widgets that default to Clips.hard.
Noted that decoration features such as shadows , which render outside the widget boundary, may lead to undesirable effects.
Recommended using Clips.none in scenarios where shadow effects are used to avoid clipping issues.
Fixing Issue #156819
2024-11-14 20:21:09 +00:00
Nate Wilson
1eaf1f9525
Add SafeArea DartPad sample (#158019)
Follow-up from #157228
2024-11-11 01:00:21 +00:00
Bruno Leroux
22a7afd99a
Fix RawScrollbar examples and desktop test (#158237)
## Description

Fix the formatting of some `RawScrollbar` examples.
Fix and rename one test file (name without `_test` suffix).
2024-11-06 08:34:36 +00:00
Valentin Vignal
ffe81f0354
Add test for raw_scrollbar.2.dart (#158161)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/widgets/scrollbar/raw_scrollbar.2.dart`
2024-11-05 23:07:57 +00:00
Valentin Vignal
fd259714d4
Add test for interactive_viewer.transformation_controller.0.dart (#157986)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/widgets/interactive_viewer/interactive_viewer.transformation_controller.0.dart`
2024-11-01 10:37:59 +00:00
miechoo
2d2ebbe263
Fix GlowingOverscrollIndicator examples (#155203)
Part of https://github.com/flutter/flutter/issues/130459

This pull request adds tests for the example files shown in the [GlowingOverscrollIndicator](https://api.flutter.dev/flutter/widgets/GlowingOverscrollIndicator-class.html) Flutter API reference documentation.
2024-10-30 20:50:00 +00:00
yim
c051b69e2a
Add boundary feature to the drag gesture. (#147521)
Inspired by the review on #146182.

This PR adds boundary feature to the drag gestures, including `MultiDragGestureRecognizer` and `DragGestureRecognizer`. The `GestureDetector` widget will also benefit from this.
2024-10-30 03:01:18 +00:00
Valentin Vignal
88d992042c
Add test for nested_scroll_view_state.0.dart (#157714)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/widgets/nested_scroll_view/nested_scroll_view_state.0.dart`
2024-10-29 02:40:41 +00:00
Valentin Vignal
b9f62f6f9f
Add test for navigator.restorable_push_replacement.0.dart (#157704)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/widgets/navigator/navigator.restorable_push_replacement.0.dart`
2024-10-28 11:23:30 +00:00
Valentin Vignal
8f5d032d78
Add tests for navigator_state.restorable_push.0.dart (#157667)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/widgets/navigator/navigator_state.restorable_push.0.dart`
2024-10-28 08:10:19 +00:00
Valentin Vignal
eef9f7129e
Add test for navigator_state.restorable_push_replacement.0.dart (#157668)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/widgets/navigator/navigator_state.restorable_push_replacement.0.dart`
2024-10-28 06:56:39 +00:00
Valentin Vignal
2d09837ed0
Add test for navigator_state.restorable_push_and_remove_until.0.dart (#157595)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/widgets/navigator/navigator_state.restorable_push_and_remove_until.0.dart`
2024-10-26 10:21:26 +00:00
Valentin Vignal
4e52defed4
Add tests for navigator.restorable_push.0.dart (#157492)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/widgets/navigator/navigator.restorable_push.0.dart`
2024-10-26 02:39:13 +00:00
Valentin Vignal
086c07cc05
Add test for build_owner.0.dart (#157499)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/widgets/framework/build_owner.0.dart`
2024-10-25 07:13:22 +00:00
Valentin Vignal
29eee6ac16
Add test for navigator.restorable_push_and_remove_until.0.dart (#157487)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/widgets/navigator/navigator.restorable_push_and_remove_until.0.dart`
2024-10-25 06:39:33 +00:00
Nate Wilson
6b1bc456f4
Arrow syntax for getters (#156483)
This egotistical PR aims to draw attention to a [style guideline](https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#use--for-getters-and-callbacks-that-just-return-literals-or-switch-expressions) that I changed:

> #### Use `=>` for getters and callbacks that just return literals or switch expressions

<br>

There was an opportunity for valuable discussion in #154753 about how this structure affects readability, but I shut it down pretty quick since there was a lot of other stuff going on there.

Interested to hear thoughts from @Piinks and others.
2024-10-17 19:25:14 +00:00
Bruno Leroux
e08ad36dd9
Remove LogicalKeySet usage in one Shortcuts example (#156941)
## Description

This PR replaces `LogicalKeySet` by `SingleActivator` in one of the Shortcuts example.
According to [LogicalKeySet documentation](https://api.flutter.dev/flutter/widgets/LogicalKeySet-class.html) :
"prefer [SingleActivator](https://api.flutter.dev/flutter/widgets/SingleActivator-class.html) when possible, whose behavior more closely resembles that of typical platforms".

## Related Issue

Related to [LogicalKeySet Not Working on Linux Environment](https://github.com/flutter/flutter/issues/156806).

## Tests

Adds 1 test.
2024-10-16 17:15:06 +00:00
RamonFarizel
51aa2f5809
Add code sample to the CupertinoMagnifier/CupertinoTextMagnifier (#156028)
This PR adds code samples regarding the CupertinoMagnifier and CupertinoTextMagnifier

Fixes #154439
2024-10-11 20:53:18 +00:00
Nate Wilson
5ecf10052f
pattern-matching refactor (#154753)
This pull request aims to improve code readability, based on feedback gathered in a recent design doc.

<br>

There are two factors that hugely impact how easy it is to understand a piece of code: **verbosity** and **complexity**.

Reducing **verbosity** is important, because boilerplate makes a project more difficult to navigate. It also has a tendency to make one's eyes gloss over, and subtle typos/bugs become more likely to slip through.

Reducing **complexity** makes the code more accessible to more people. This is especially important for open-source projects like Flutter, where the code is read by those who make contributions, as well as others who read through source code as they debug their own projects.

<hr>

<br>

The following examples show how pattern-matching might affect these two factors:

<details> <summary><h3>Example 1 (GOOD)</h3> [click to expand]</summary>

```dart
if (ancestor case InheritedElement(:final InheritedTheme widget)) {
  themes.add(widget);
}
```

Without using patterns, this might expand to

```dart
if (ancestor is InheritedElement) {
  final InheritedWidget widget = ancestor.widget;
  if (widget is InheritedTheme) {
    themes.add(widget);
  }
}
```

Had `ancestor` been a non-local variable, it would need to be "converted" as well:

```dart
final Element ancestor = this.ancestor;
if (ancestor is InheritedElement) {
  final InheritedWidget inheritedWidget = ancestor.widget;
  if (widget is InheritedTheme) {
    themes.add(theme);
  }
}
```

</details>

<details> <summary><h3>Example 2 (BAD) </h3> [click to expand]</summary>

```dart
if (widget case PreferredSizeWidget(preferredSize: Size(:final double height))) {
  return height;
}
```

Assuming `widget` is a non-local variable, this would expand to:

```dart
final Widget widget = this.widget;
if (widget is PreferredSizeWidget) {
  return widget.preferredSize.height;
}
```

<br>

</details>

In both of the examples above, an `if-case` statement simultaneously verifies that an object meets the specified criteria and performs a variable assignment accordingly.

But there are some differences: Example 2 uses a more deeply-nested pattern than Example 1 but makes fewer useful checks.

**Example 1:**
- checks that `ancestor` is an `InheritedElement`
- checks that the inherited element's `widget` is an `InheritedTheme`

**Example 2:**
- checks that `widget` is a `PreferredSizeWidget`
(every `PreferredSizeWidget` has a `size` field, and every `Size` has a `height` field)

<br>

<hr>

I feel hesitant to try presenting a set of cut-and-dry rules as to which scenarios should/shouldn't use pattern-matching, since there are an abundance of different types of patterns, and an abundance of different places where they might be used.

But hopefully the conversations we've had recently will help us converge toward a common intuition of how pattern-matching can best be utilized for improved readability.

<br><br>

- resolves https://github.com/flutter/flutter/issues/152313
- Design Doc: [flutter.dev/go/dart-patterns](https://flutter.dev/go/dart-patterns)
2024-10-03 18:21:04 +00:00
Mitchell Goodwin
d877d2875e
Allow mixing route transitions in one app. (#150031)
Fixes #33799

Allows for a route to inform the route below it in the navigation stack how to animate when the topmost route enters are leaves the stack.

It does this by making a `DelegatedTransition` available for the previous route to look up and use. If available, the route lower in the stack will wrap it's transition builders with that delegated transition and use it instead of it's default secondary transition.

This is what the sample code in this PR shows an app that is able to use both a Material zoom transition and a Cupertino slide transition in one app. It also includes a custom vertical transition. Every page animates off the screen in a way to match up with the incoming page's transition. When popped, the correct transitions play in reverse.

https://github.com/user-attachments/assets/1fc910fa-8cde-4e05-898e-daad8ff4a697

The below video shows this logic making a pseudo iOS styled sheet transition.

https://github.com/flutter/flutter/assets/58190796/207163d8-d87f-48b1-aad9-7e770d1d96c5

All existing page transitions in Flutter will be overwritten by the incoming route if a `delegatedTransition` is provided. This can be opted out of through `canTransitionTo` for a new route widget. Of Flutter's existing page transitions, this PR only adds a `DelegatedTransition` for the Zoom and Cupertino transitions. The other transitions possible in Material will get delegated transitions in a later PR.
2024-10-02 20:08:11 +00:00
Kostia Sokolovskyi
591cc39c2d
Add WidgetStateMouseCursor example and tests for it. (#155552)
Fixes https://github.com/flutter/flutter/issues/155551

### Description
- Adds example for `WidgetStateMouseCursor`
- Adds tests for `examples/api/lib/widgets/widget_state/widget_state_mouse_cursor.0.dart`
2024-10-01 23:15:53 +00:00
Taha Tesser
9f88de930b
Optimize Overlay sample to avoid overflow (#155861)
Fixes [Optimize official `Overlay` sample to avoid overflowing.](https://github.com/flutter/flutter/issues/155860)

When checking https://main-api.flutter.dev/flutter/widgets/Overlay-class.html on a laptop screen it overflows as the layout uses Row instead of more robust widget for spacing `Wrap`

Quick Friday night fix. :) 

| Before | After |
| --------------- | --------------- |
| <img src="https://github.com/user-attachments/assets/eea6f1d9-e860-4ebd-8d16-2d8f4141e1ec" /> | <img src="https://github.com/user-attachments/assets/9f8426ba-d541-44a6-8ea6-2e34636b7e82"  /> |
2024-09-28 09:20:32 +00:00
Kostia Sokolovskyi
ce24dd6a76
Add WidgetStateBorderSide example and tests for it. (#155559)
Fixes https://github.com/flutter/flutter/issues/155557

### Description
- Adds example for `WidgetStateBorderSide`
- Adds tests for `examples/api/lib/widgets/widget_state/widget_state_border_side.0.dart`
2024-09-25 15:53:28 +00:00
Kostia Sokolovskyi
96ba3c555a
Add WidgetStateProperty example and tests for it. (#155315)
This PR contributes to https://github.com/flutter/flutter/issues/155313

### Description
- Adds example for `WidgetStateProperty`
- Adds tests for `examples/api/lib/widgets/widget_state/widget_state_property.0.dart`
2024-09-24 00:31:07 +00:00
Mansour Alhaddad
a43c401c67
Add test for error_widget.0_test.dart (#153103)
Add test for error_widget.0_test.dart which is listed in this issue 

related to this issue https://github.com/flutter/flutter/issues/130459
2024-08-26 18:11:02 +00:00
Justin McCandless
420755dcfa
Nested Navigator state restoration predictive back examples (#153723)
I've updated these two examples to support state restoration of the navigation stack and verified that they work with predictive back in the tests. This was motivated by a worry that users are not properly setting up their navigation and that our examples are misleading them in the name of simplicity.
2024-08-22 03:40:09 +00:00
Nate Wilson
6ff806d74e
Use .fromMap() constructors in example code (#152535)
Currently, there are 21 `.resolveWith()` calls in example files.

This pull request changes 11 of them to use the new `.fromMap()` constructor. (Seven of them are now `const`!)

```dart
ListTile(
  iconColor: WidgetStateColor.fromMap(<WidgetStatesConstraint, Color>{
    WidgetState.disabled: Colors.red,
    WidgetState.selected: Colors.green,
    WidgetState.any:      Colors.black,
  }),
  // The same can be achieved using the .resolveWith() constructor.
  // The text color will be identical to the icon color above.
  textColor: WidgetStateColor.resolveWith((Set<WidgetState> states) {
    if (states.contains(WidgetState.disabled)) {
      return Colors.red;
    }
    if (states.contains(WidgetState.selected)) {
      return Colors.green;
    }
    return Colors.black;
  }),
),
```
2024-08-01 22:28:22 +00:00
Huy
7d5c1c04fb
Enhances intuitiveness of RawMagnifier's example (#150308)
### Demo

| Before | After |
| --------------- | --------------- |
<video src="https://github.com/flutter/flutter/assets/104349824/ee6d45f1-bcf0-4136-8d1d-a642e0767322"/> | <video src="https://github.com/flutter/flutter/assets/104349824/1e2bb33d-40f1-4cf6-9999-f67bef638633"/>

### Related issue

Fixes https://github.com/flutter/flutter/issues/150307
2024-07-19 14:09:18 +00:00
Michael Goderbauer
43f3252c82
docimports for API samples (#151606)
Part of https://github.com/flutter/flutter/issues/150800

Turns out: None of these actually need any docImports. They just had broken references.
2024-07-11 20:36:55 +00:00
Nate Wilson
b713445298
Factor out deprecated names in example code (#151374)
This PR contains:
- 3 instances of `colorScheme.background` → `colorScheme.surface`
- and a whole bunch of `MaterialState` → `WidgetState`

As of yet, no changes have been made to example test files or the [examples/api/lib/material/material_state/](0b2a8e589e/examples/api/lib/material/material_state) directory.

(related: #151373)
2024-07-08 19:06:54 +00:00
Hans Muller
abd7cd0528
PinnedHeaderSliver example based on the iOS Settings AppBar (#151205)
A relatively elaborate PinnedSliverHeader example which creates an app bar that's similar to the one that appears in the iOS Settings app. In this example the pinned header starts out transparent and the first item in the list serves as the app's "Settings" title. When the title item has been scrolled completely behind the pinned header, the header animates its opacity from 0 to 1 and its (centered) "Settings" title appears. The fact that the header's opacity depends on the height of the title item - which is unknown until the list has been laid out - necessitates monitoring its SliverConstraints.scrollExtent from a scroll NotificationListener. 

https://github.com/flutter/flutter/assets/1377460/539e2591-d0d7-4508-8ce8-4b8f587d7648
2024-07-03 20:06:16 +00:00
Hans Muller
d1e150099e
SliverFloatingHeader (#151145)
A sliver that shows its [child] when the user scrolls forward and hides it when the user scrolls backwards. Similar headers can be found in  Google Photos and Facebook.

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

https://github.com/flutter/flutter/assets/1377460/82b67dfb-5d38-4adf-9415-fc8527d0eb9f
2024-07-03 19:52:52 +00:00
Michael Goderbauer
56835d6039
Fix references in examples (#151204)
Part of https://github.com/flutter/flutter/issues/150800
2024-07-03 17:56:48 +00:00
Snoppy
65cd7cf7b2
chore: fix typos and link broken (#150402)
**fix some typos and link broken**
2024-07-03 17:10:19 +00:00
Hans Muller
acb41f3174
ScrollEndNotification example: auto-scroll based on RenderSliver constraints and geometry (#143538)
Adds a new ScrollNotificationEnd example that demonstrates how to trigger an auto-scroll based on an individual sliver's `SliverConstraints` and `SliverGeometry`. 

Then new example auto-scrolls one special "aligned item" sliver to the top or bottom of the viewport, whenever it's partially visible (because it overlaps the top or bottom of the viewport). This example differs from the existing ScrollEndNotification example because the layout of the to-be aligned sliver is retrieved from its `RenderSliver` via a
GlobalKey.  The new example does not rely on all of the list items having the same extent.
2024-07-02 18:46:19 +00:00
Kate Lovett
9b6813f4da
Reland TreeSliver (#149839)
Reland of https://github.com/flutter/flutter/pull/147171

It was reverted for a failing unit test that had passed in presubmit. Hopefully this sticks better.
Also fixed leaks in 37b10adc90
2024-06-17 19:49:05 +00:00
Hans Muller
9ce0a9e510
PinnedHeaderSliver (#143196)
A sliver that remains “pinned” to the top of the scroll view. Subsequent slivers scroll behind it. Typically the sliver is created as the first item in the list however it can be inserted anywhere and it will always stop at the top of the scroll view. When the scrolling axis is vertical, the PinnedHeaderSliver’s height is defined by its widget child. Multiple PinnedHeaderSlivers will layout one after the other, once they've scrolled to the top.

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

Here's a [working demo in DartPad](https://dartpad.dev/?id=3b3f24c14fa201f752407a21ca9c9456).

https://github.com/flutter/flutter/assets/1377460/943f2e02-8e73-48b7-90be-61168978ff71

Related sliver utility PRs: https://github.com/flutter/flutter/pull/143538, https://github.com/flutter/flutter/pull/143325, https://github.com/flutter/flutter/pull/127340.
2024-06-07 21:27:06 +00:00
Hans Muller
7e3e30929a
SliverResizingHeader (#143325)
A sliver that is pinned to the start of its `CustomScrollView` and reacts to scrolling by resizing between the intrinsic sizes of its min and max extent prototypes.

The minimum and maximum sizes of this sliver are defined by `minExtentPrototype` and `maxExtentPrototype`, a pair of widgets that are laid out once. You can use `SizedBox` widgets to define the size limits.

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

The sample shows how this sliver's two extent prototype properties can be used to create a resizing header whose minimum and maximum sizes match small and large configurations of the same header widget.

https://github.com/flutter/flutter/assets/1377460/fa7ced98-9d92-4d13-b093-50392118c213

Related sliver utility PRs: https://github.com/flutter/flutter/pull/143538, https://github.com/flutter/flutter/pull/143196, https://github.com/flutter/flutter/pull/127340.
2024-06-06 22:35:12 +00:00
auto-submit[bot]
27e06569a1
Reverts "TreeSliver & associated classes (#147171)" (#149754)
Reverts: flutter/flutter#147171
Initiated by: QuncCccccc
Reason for reverting: tree is red due to a test in this PR
Original PR Author: Piinks

Reviewed By: {QuncCccccc, TahaTesser, bleroux}

This change reverts the following previous change:
**FYI for Reviewers:** Much of the API surface matches that of the 2D TreeView in https://github.com/flutter/packages/pull/6592. If it changes here, it should change there, and vice versa.

📜  [Design Document](https://docs.google.com/document/d/1-aFI7VjkF9yMkWpP94J8T_JREDS-M3bOak26PVehUYg/edit?usp=sharing)

This adds classes and associated callbacks and controllers for TreeSliver. Core components:
- TreeSliver
- RenderTreeSliver
- TreeSliverNode
- TreeSliverController
- TreeSliverStateMixin
- TreeSliverIndentationType

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

https://github.com/flutter/flutter/assets/16964204/3facd095-7262-4068-aa33-d713e2deca99

https://github.com/flutter/flutter/assets/16964204/f851ae30-8e71-45c7-82a4-9606986a5872
2024-06-05 17:17:19 +00:00