Commit Graph

520 Commits

Author SHA1 Message Date
Nate Wilson
06c3c93d72
const AnimationStyle (#160564)
[**AnimationStyle**](https://main-api.flutter.dev/flutter/animation/AnimationStyle-class.html)
is an
[`@immutable`](https://main-api.flutter.dev/flutter/meta/immutable-constant.html)
class with all `final` fields.

This pull request gives it a `const` constructor.

<br>

related: #160563
2025-01-22 21:52:11 +00:00
Michael Goderbauer
9cab4ffee1
Use wildcards (#161548)
https://dart.dev/language/pattern-types#wildcard
2025-01-14 05:13:41 +00:00
Mitchell Goodwin
50f7120de5
CupertinoSheetRoute (#157568)
Fixes #42560

### Updated 12/04/24

Adds a CupertinoSheetRoute which displays an iOS style sheet, while
giving the previous route a delegated transition to sync up correctly.

There's a lot of sample files in this draft showing different use cases
for the sake of reviewing the PR. We'll want to probably go down to
about two before this PR lands.

**TODO in this PR**

- [x] Write actual documentation
- [x] Write tests

**TODO in a feature branch, and will be merged with this PR**

- [ ] Add swipe down to dismiss

**TODO in a follow up PR**

- [ ] Stretching on swipe up
- [ ] Add a fullscreen version
- [x] Dark mode theming

How it currently compares, with the simple case and nested navigation:
| Flutter  | Native|
| ------------- | ------------- |
|
![Flutter-Simple](https://github.com/user-attachments/assets/2a1f277e-91c9-48e0-b894-5fad71ef6a21)
|![Native-Simple](https://github.com/user-attachments/assets/6960252a-f762-4ad8-8d68-5c3d7cf8d4e7)
|
|
![Flutter-Nested](https://github.com/user-attachments/assets/bacb3e35-9d11-4113-9331-75daaded67e7)
|
![Native-stacked](https://github.com/user-attachments/assets/70ccbbbb-24c2-40b5-b838-4f8412828b9b)
|

Update:

![Flutter-Status-Bar](https://github.com/user-attachments/assets/c738cc5c-7176-4df2-9422-6b3fa608c943)
Now the status bar will transition from dark to light text so that it's
visible after the transition.

`cupertino_sheet.0.dart` has an example of what it looks like to do a
simple case. It's fairly straightforward.

`cupertino_sheet.1.dart` shows one with nested navigation. It's
necessary to add a `Navigator` if showing page navigation within the
sheet is wanted. I'm thinking adding an API option that auto sets this
up may be needed as there are some pitfalls.

`cupertino_sheet.2.dart` functionally does the same as above but uses
the `showCupertinoSheet` to reduce boilerplate.

## 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
2025-01-10 23:01:08 +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
Taha Tesser
689924529b
Updated Material 3 Slider Samples (#159795)
Fixes [Update `Slider` samples for updated Material 3 Slider
spec](https://github.com/flutter/flutter/issues/159794)

### Description

This updates Slider sample to include toggle to opt in to the updated
Material 3 appearance . Remove redundant sample an asset diagram.

### Preview

<img width="840" alt="Screenshot 2024-12-04 at 16 03 47"
src="https://github.com/user-attachments/assets/b6db9efe-8416-460e-a745-bdf37c97ed61">


## 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].
- [ ] 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-05 17:55:24 +00:00
Taha Tesser
a6d3bb5cb4
Updated Material 3 Progress Indicators Samples (#158925)
Fixes [Update both `ProgressIndicator` for Material 3
redesign](https://github.com/flutter/flutter/issues/141340)

> [!IMPORTANT]  
> ~~This to be merged after
https://github.com/flutter/flutter/pull/158104.~~ Merged.

### Description 

This updates progress indicator samples to include toggle to opt in to
the updated Material 3 appearance .

### Preview

<img width="753" alt="Screenshot 2024-12-04 at 15 54 50"
src="https://github.com/user-attachments/assets/285f2803-1a12-470a-9afe-2abcf0548ff4">

<img width="753" alt="Screenshot 2024-12-04 at 15 58 35"
src="https://github.com/user-attachments/assets/9caebec9-f65e-4baa-8e39-9a4a4a72b205">


## 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].
- [ ] 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-05 17:54:54 +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
Renzo Olivares
f3f72ede04
Add SelectionListener/SelectedContentRange (#154202)
https://github.com/user-attachments/assets/59225cf7-5506-414e-87da-aa4d3227e7f6

Adds:
* `SelectionListener`, allows a user to listen to selection changes
under the subtree it wraps given their is an ancestor `SelectionArea` or
`SelectableRegion`. These selection changes can be listened to through
the `SelectionListenerNotifier` that is provided to a
`SelectionListener`.
* `SelectionListenerNotifier`, used with `SelectionListener`, allows a
user listen to selection changes for the subtree of the
`SelectionListener` it was provided to. Provides access to individual
selection values through the `SelectionDetails` object `selection`.
* `SelectableRegionSelectionStatusScope`, allows the user to listen to
when a parent `SelectableRegion` is changing or finalizing the
selection.
* `SelectedContentRange`, provides information about the selection range
under a `SelectionHandler` or `Selectable` through the `getSelection()`
method. This includes a start and end offset relative to the
`Selectable`s content.
* `SelectionHandler.contentLength`, to describe the length of the
content contained by a selectable.

Original PR & Discussion: https://github.com/flutter/flutter/pull/148998

Fixes: #110594

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

---------

Co-authored-by: Renzo Olivares <roliv@google.com>
2024-11-26 00:14:30 +00:00
Christofer
c2309f3a9e
Fix NavigationBar example overflow alignment (#159034)
Fix the NavigationBar example overflow alignment.

### Before: 
<img
src="https://github.com/user-attachments/assets/a6cf2cbb-ac32-482c-9aed-8cac15152a0d"
height="450" />


### After:
<img
src="https://github.com/user-attachments/assets/d476c617-edd3-449d-93cf-4a9a87c26d98"
height="450" />



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

*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
2024-11-16 22:24:39 +00:00
Greg Spencer
4d3bbf30c8
Make the focus node on SelectableRegion optional. (#158994)
## Description

This makes the `focusNode`  for `SelectableRegion` optional so that:
- Users of the widget are no longer required to use `SelectableRegion`
from within a `StatefulWidget`
- They aren't likely to forget to dispose of a node they didn't supply.
- Simpler to use, and the node is not used very often anyhow.

Also made the `SelectableRegion` sample actually use `SelectableRegion`.

## Tests
- Modified all the `SelectableRegion` tests to remove 3 identical lines
of boilerplate from each (except 2, which actually used their focus
nodes).
2024-11-15 22:39:41 +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
Valentin Vignal
c1ee381b18
Reland Add test for dynamic_content_color.0.dart (#158547)
Fixes https://github.com/flutter/flutter/issues/130459

Follow up of the reverted https://github.com/flutter/flutter/pull/158309

It adds a test for
- `examples/api/lib/material/color_scheme/dynamic_content_color.0.dart`
2024-11-14 08:14:17 +00:00
auto-submit[bot]
423aa2ac74
Reverts "Add test for dynamic_content_color.0.dart (#158309)" (#158511)
Reverts: flutter/flutter#158309
Initiated by: bleroux
Reason for reverting: added test is failing on CI

Original PR Author: ValentinVignal

Reviewed By: {bleroux}

This change reverts the following previous change:
Fixes https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/material/color_scheme/dynamic_content_color.0.dart`
2024-11-12 16:05:17 +00:00
Valentin Vignal
95a9b97f88
Add test for dynamic_content_color.0.dart (#158309)
Fixes https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/material/color_scheme/dynamic_content_color.0.dart`
2024-11-12 11:49:24 +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
Taha Tesser
b8dcb0c3c5
Update Material 3 LinearProgressIndicator for new visual style (#154817)
Related to [Update both `ProgressIndicator` for Material 3 redesign](https://github.com/flutter/flutter/issues/141340)

### Code sample

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

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

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool isRTL = false;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(

        body: Directionality(
          textDirection: isRTL ? TextDirection.rtl : TextDirection.ltr,
          child: Center(
            child: Column(
              spacing: 2.0,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                const Text('Default LinearProgressIndicator'),
                const Padding(
                  padding: EdgeInsets.all(16.0),
                  child: LinearProgressIndicator(
                    value: 0.45,
                  ),
                ),
                const Text('Default indefinite LinearProgressIndicator'),
                const Padding(
                  padding: EdgeInsets.all(16.0),
                  child: LinearProgressIndicator(),
                ),
                const Text('Updated height and border radius'),
                Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: LinearProgressIndicator(
                    value: 0.25,
                    minHeight: 16.0,
                    borderRadius: BorderRadius.circular(16.0),
                  ),
                ),
                const Text('Updated stop indicator color and radius'),
                Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: LinearProgressIndicator(
                    value: 0.74,
                    minHeight: 16.0,
                    borderRadius: BorderRadius.circular(16.0),
                    stopIndicatorColor: Theme.of(context).colorScheme.error,
                    stopIndicatorRadius: 32.0,
                  ),
                ),
                const Text('Track gap and stop indicator radius set to 0'),
                Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: LinearProgressIndicator(
                    value: 0.50,
                    minHeight: 16.0,
                    borderRadius: BorderRadius.circular(16.0),
                    trackGap: 0,
                    stopIndicatorRadius: 0,
                  ),
                ),
              ],
            ),
          ),
        ),
        floatingActionButton: FloatingActionButton.extended(
          onPressed: () {
            setState(() {
              isRTL = !isRTL;
            });
          },
          label:  const Text('Toggle Direction'),
        ),
      ),
    );
  }
}
```

</details>

### Preview

<img width="824" alt="Screenshot 2024-09-09 at 13 53 10" src="https://github.com/user-attachments/assets/d12e56a5-f196-4011-8266-c7ab96be96b2">
2024-10-30 18:14:11 +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
Kate Lovett
2c20325af4
Update CupertinoNavigationBar to support large layout (#157133)
Fixes https://github.com/flutter/flutter/issues/149625

This adds a new constructor CupertinoNavigationBar.large for the large style navigation bar. CupertinoSliverNavigationBar enables dynamically changing between the smaller and larger layouts for native iOS headers in response to scrolling, this change makes it possible to configure the static navigation bar in one style or the other.
2024-10-25 19:08:12 +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
Huy
fa5254331f
Add ability to disable CupertinoSegmentedControl (#152813)
### Summary

Add the ability to configure enabled or disabled segments in CupertinoSegmentedControl. The idea is to pass a `segmentStates` map, where the user can set the state according to segment key. User can also set background and text colors when the segment is disabled.

### Demo

https://github.com/user-attachments/assets/4a02da02-a0fb-4ded-a271-033a8dc79ac3

### Related issue
Fixes https://github.com/flutter/flutter/issues/52105
2024-10-24 12:05:35 +00:00
Nate Wilson
ea0fda51ef
WidgetStateInputBorder (#157190)
**Changes**
- Add `WidgetStateInputBorder` class, with `.resolveWith()` and `.fromMap()` constructors
- Deprecate `MaterialStateOutlineInputBorder` and `MaterialStateUnderlineInputBorder` and provide data-driven fixes

<br>

**Other changes** based on https://github.com/flutter/flutter/pull/154972#pullrequestreview-2344092821
- Fix documentation copy-paste typo ("OutlinedBorder" → "InputBorder")
- Add test to ensure borders are painted correctly
- Add DartPad sample & relevant test
2024-10-22 23:45:41 +00:00
Jiten Patel
3e9901dac9
Fix: showDatePicker should have a simple example in the docs (#156196)
This PR introduces a basic example of how to use the `showDatePicker` function. The purpose of this PR is to simplify the onboarding process for new Flutter developers by providing a straightforward demonstration of handling the asynchronous Future returned by the showDatePicker. This will help users unfamiliar with the intricacies of asynchronous operations in Flutter.

Fixes #156157
2024-10-22 17:04:23 +00:00
Valentin Vignal
a484aa260b
Add test for selectable_region.0.dart (#157258)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/test/material/selectable_region/selectable_region.0_test.dart`
2024-10-22 07:25:25 +00:00
Valentin Vignal
3405f11e5c
Add test for flexible_space_bar.0.dart (#157107)
Contributes to https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/test/material/flexible_space_bar/flexible_space_bar.0_test.dart`
2024-10-21 15:17:14 +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
Victor Sanni
f9eebe0319
Add bottom to CupertinoNavigationBar to allow for a double-row nav bar (#155959)
Fixes [Support segmented controls in nav bars and double row nav bars](https://github.com/flutter/flutter/issues/10469)

<img width="270" height="600"  alt="Screenshot 2024-09-30 at 3 09 04 PM" src="https://github.com/user-attachments/assets/4003116f-69dd-4f8f-a185-6ca151b74d2d">
2024-10-16 19:36:55 +00:00
Victor Sanni
293ae2e5ab
Add bottom to CupertinoSliverNavigationBar (#155841)
Fixes [Support search box inside large title nav bar](https://github.com/flutter/flutter/issues/18103)
Part of [Support segmented controls in nav bars and double row nav bars](https://github.com/flutter/flutter/issues/10469)

## None mode (Current default)

https://github.com/user-attachments/assets/d798314e-940f-4311-9a9a-fe999c65f280

## Always mode

https://github.com/user-attachments/assets/950a85aa-8ca2-42ea-bf8b-3cb8f95e616e

## Automatic mode

https://github.com/user-attachments/assets/c7c7240b-d493-4036-a987-30f61d02bac3

## With CupertinoSlidingSegmentedControl

https://github.com/user-attachments/assets/59f4aec4-8d9c-4223-915b-97b73cb25dc8

<details>
<summary>Sample Code</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/cupertino.dart';

/// Flutter code sample for [CupertinoSliverNavigationBar].

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

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

  @override
  Widget build(BuildContext context) {
    return const CupertinoApp(
      theme: CupertinoThemeData(brightness: Brightness.light),
      home: SliverNavBarExample(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return const CupertinoPageScaffold(
      // A ScrollView that creates custom scroll effects using slivers.
      child: SafeArea(
        child: CustomScrollView(
          // A list of sliver widgets.
          slivers: <Widget>[
            CupertinoSliverNavigationBar(
              leading: SizedBox(
                width: 100,
                child: Row(
                  children: [
                    Icon(CupertinoIcons.back),
                    Text(
                      'Lists',
                      style: TextStyle(color: CupertinoColors.activeBlue),
                    ),
                  ],
                ),
              ),
              trailing: Icon(CupertinoIcons.plus),
              largeTitle: Text('iPhone'),
              // Change to desired mode.
              drawerMode: NavigationDrawerMode.none,
              drawer: Padding(
                padding: EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 16.0),
                child: CupertinoSearchTextField(),
              ),
            ),
            SliverFillRemaining(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Text('Drag me up', textAlign: TextAlign.center),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
```

</details>
2024-10-16 18:25:06 +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
Bruno Leroux
480869afe7
Update MenuAnchor API examples (#156404)
## Description

Cleanup MenuAnchor API examples:
- Remove usage of useMaterial3
- fix some formatting issues
2024-10-08 19:15:07 +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
Sikandar Sadaqat
d355a474f9
[Docs] CupertinoListTile API Example (#154548)
This PR adds an example for CupertinoListTile

Fixes: https://github.com/flutter/flutter/issues/154438
2024-10-02 15:24:05 +00:00
Bruno Leroux
21381d843f
Fix DropdownMenu does not rematch initialSelection when entries have changed (#155757)
## Description

This PR makes DropdownMenu rematching the initialSelection when the entries are updated.
If the new entries contains one entry whose value matches `initialSelection` this entry's label is used to initialize the inner text field, if no entries matches `initialSelection` the text field is emptied.

## Related Issue

Fixes [DropdownMenu.didUpdateWidget should re-match initialSelection when dropdownMenuEntries have changed](https://github.com/flutter/flutter/issues/155660).

## Tests

Adds 3 tests.
2024-10-02 12:03:20 +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
Denis Gordin
31d6b35b7f
Move FlutterLogo from material to widget (#155864)
The PR is moving FlutterLogo from `lib/src/material` to `lib/src/widgets` because it has no dependency on Material.

Issue: https://github.com/flutter/flutter/issues/154448

PS: There is [older PR](https://github.com/flutter/flutter/pull/154711) for this issue and I don't know the policy on conflicting PRs. Let me know if I need to drop mine.
2024-09-30 17:19:25 +00:00