7463 Commits

Author SHA1 Message Date
Binni Goel
77c19f50c1
Test cover cupertino for memory leaks and fix Opacity Layer not disposed. (#136576) 2023-10-15 12:26:52 -07:00
Binni Goel
0f5550461e
Test cover cupertino for memory leaks tracking -2 (#136577) 2023-10-15 12:25:27 -07:00
Kostia Sokolovskyi
2c3db435a8
_RouterState should dispose created _RestorableRouteInformation. (#136556)
### Description
- Fixes https://github.com/flutter/flutter/issues/134205.

### Tests
- Removes ignoring the `_RestorableRouteInformation` leak from `cupertino/app_test.dart`;
- Removes ignoring the `_RestorableRouteInformation` leak from `material/app_test.dart`;
- Removes ignoring the `_RestorableRouteInformation` leak from `widgets/app_test.dart`;
- Removes ignoring the `_RestorableRouteInformation` leak from `widgets/route_notification_messages_test.dart`;
- Removes ignoring the `_RestorableRouteInformation` leak from `widgets/router_restoration_test.dart`;
- Updates `widgets/router_test.dart` to use `testWidgetsWithLeakTracking`.
2023-10-14 02:58:17 +00:00
Daniel Chevalier
ac095ed393
Changes WidgetInspector to use valuenotifier instead of a force rebuild for (#131634)
![](https://media.giphy.com/media/qriH9W51oLsL6/giphy.gif)
Fixes https://github.com/flutter/devtools/issues/6014

Change the forceRebuild behaviour of the WidgetInspector to use
ValueListenableBuilders instead. This should help resolve heavy rebuilds
when the widgetInspectorOverride value changes.
2023-10-13 17:07:57 -04:00
Polina Cherkasova
9f512d7037
Mark leak in NativeCodec.getNextFrame. (#136514) 2023-10-13 11:57:57 -07:00
Polina Cherkasova
2ea541aca9
Stop skipping leaks in the test. (#136512) 2023-10-13 11:55:58 -07:00
droidbg
86c9b8ea8c
[leak-tracking] Add leak tracking in test/rendering -2 (#136310) 2023-10-13 10:08:11 -07:00
droidbg
8f14104c7d
[leak-tracking] Add leak tracking in test/rendering -3 (#136308) 2023-10-13 10:06:55 -07:00
Kostia Sokolovskyi
7d79472531
SearchAnchor should dispose created FocusNode and SearchController. (#136120) 2023-10-12 19:35:46 -07:00
Todd Volkert
bc688cf0df
Make constraints a covariant argument in RenderBox.computeDryLayout() (#136432)
Some render box subclasses have a specific layout contract that is tightly coupled with other render box subclasses (e.g. two private classes in a local project file). In these cases, it is also possible that they use a constraints object that is a subclass of `BoxConstraints`. To allow for this, this change makes the `constraints` argument to `RenderBox.computeDryLayout()` a covariant argument.

For completeness' sake, this updates the other render objects in the rendering package to also use the covariant keyword for this argument.
2023-10-13 01:10:29 +00:00
xubaolin
3f722c1442
[SingleChildScrollView] Correct the offset pixels if it is out of range during layout (#136239)
Fixes https://github.com/flutter/flutter/issues/105733
FIxes https://github.com/flutter/flutter/issues/135865

The above two issues will not occur on the `ListView` widget, so after analyzing their differences, it was found that the `SingleChildScrollView` pixels were not corrected according to the content dimensions during layout.

### ListView correct the pixels codes
5dfd78c2e3/packages/flutter/lib/src/rendering/viewport.dart (L1462-L1465)

We should correct the pixels to prevent the physics ballistic simulations.

This change makes them have the same behavior.
2023-10-12 21:25:09 +00:00
Greg Spencer
22b0a62a0c
Allow TapRegion to consume tap events (#136305)
## Description

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

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

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

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

## Tests
 - Added tests for `TapRegion` to make sure taps are consumed properly.
2023-10-12 21:04:41 +00:00
Taha Tesser
f65dd3bac0
Fix chip widgets don't the apply provided iconTheme (#135751)
fixes [`Chip.iconTheme` does not apply the icon theme](https://github.com/flutter/flutter/issues/111828)

### Description
- Fix chip widgets that don't utilize the provided `iconTheme`.
- Prevent `iconTheme` with just color from overriding the default icon size.
- Add some missing M3 tests for the chip and chip theme properties.

### Code sample

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

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(useMaterial3: true),
      home: const Example(),
    );
  }
}

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

  @override
  State<Example> createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  final bool _isEnable = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
            RawChip(
              iconTheme: const IconThemeData(color: Colors.amber),
              avatar: const Icon(Icons.favorite_rounded),
              label: const Text('RawChip'),
              onPressed: () {},
              isEnabled: _isEnable,
            ),
            const Chip(
              iconTheme: IconThemeData(color: Colors.amber),
              avatar: Icon(Icons.favorite_rounded),
              label: Text('Chip'),
              // onDeleted: () {},
            ),
            FilterChip(
              iconTheme: const IconThemeData(color: Colors.amber),
              avatar: const Icon(Icons.favorite_rounded),
              label: const Text('FilterChip'),
              selected: false,
              onSelected: _isEnable ? (bool value) {} : null,
            ),
            InputChip(
              iconTheme: const IconThemeData(color: Colors.amber),
              avatar: const Icon(Icons.favorite_rounded),
              label: const Text('InputChip'),
              isEnabled: _isEnable,
              onPressed: () {},
            ),
            ActionChip(
              iconTheme: const IconThemeData(color: Colors.amber),
              avatar: const Icon(Icons.favorite_rounded),
              label: const Text('ActionChip'),
              onPressed: _isEnable ? () {} : null,
            ),
            ChoiceChip(
              iconTheme: const IconThemeData(color: Colors.amber),
              avatar: const Icon(Icons.favorite_rounded),
              label: const Text('ChoiceChip'),
              selected: false,
              onSelected: _isEnable ? (bool value) {} : null,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {},
        child: const Icon(Icons.add),
      ),
    );
  }
}

```

</details>

### Before
![Screenshot 2023-09-29 at 16 59 39](https://github.com/flutter/flutter/assets/48603081/4bc32032-cff3-4237-812f-86f17ed95337)

### After

![Screenshot 2023-09-29 at 16 55 24](https://github.com/flutter/flutter/assets/48603081/05a1fc52-fb31-4790-a840-18f2e9718241)
2023-10-12 14:17:56 +00:00
Qun Cheng
6388e3d727
Floating SnackBar should always float above the bottom widgets (#136411)
Fixes #136162

This PR is to fix the floating `SnackBar` issue so that when the top of the bottom bar is higher than the top of the FAB, the snack bar will still float and not be clipped.

| Before fix | After fix |
|--------|--------|
| ![Screenshot 2023-10-11 at 1 54 30 PM](https://github.com/flutter/flutter/assets/36861262/dbe02312-1a80-4532-9bad-a8f162a6a942) | ![Screenshot 2023-10-11 at 1 54 52 PM](https://github.com/flutter/flutter/assets/36861262/68211de0-f04f-4b1a-b554-baf6a8e2f947)
 |
2023-10-12 01:17:07 +00:00
Bryan Olivares
d9c0d3ae51
SearchBar should listen to changes to the SearchController and update suggestions on change (#134337)
This PR is adding a listener to the `SearchController`, so that the `suggestionBuilder` can be updated when the `SearchController` changes. 

Another method we can possibly do is  have an update method on `SearchController`, so that the user can manually update the suggestions instead of us doing it automatically.

Fixes #132161
2023-10-12 00:55:38 +00:00
droidbg
f84831c169
[leak-tracking] Add leak tracking in test/rendering - 1 (#136275) 2023-10-11 11:53:41 -07:00
Kenzie Davisson
a047358c5c
Add profilePlatformChannels service extension (#136051)
We will expose this from a button in DevTools.
https://github.com/flutter/devtools/issues/6166
2023-10-11 10:45:06 -07:00
Maximilian Fischer
6ff02dbc83
Include size factors when computing the intrinsic size of a RenderPositionedBox (#135823)
This PR includes the `widthFactor` and `heightFactor` when computing the intrinsic size of a `RenderPositionedBox`.

<details><summary>Code sample</summary>

Red should have a height of 100, blue one of 200.

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Intrinsic Bug',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: Scaffold(
        body: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Expanded(
              child: IntrinsicHeight(
                child: Align(
                  heightFactor: 0.5,
                  child: Container(
                    height: 200,
                    color: Colors.red,
                  ),
                ),
              ),
            ),
            Expanded(
              child: Container(
                height: 200,
                color: Colors.blue,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
```
</details>

Before:
![grafik](https://github.com/flutter/flutter/assets/45403027/447d8b9b-e7f3-482a-900d-53e436830321)
After:
![grafik](https://github.com/flutter/flutter/assets/45403027/6d1a104b-3327-47e2-8b36-798ed0136793)

Fix #135822
2023-10-11 17:39:56 +00:00
Kostia Sokolovskyi
cc41e25f21
_RenderSnapshotWidget should dispose created OffsetLayer. (#136267) 2023-10-11 08:45:39 -07:00
Taha Tesser
692d7ade9e
Fix FlexibleSpaceBar does compositing with near zero opacity. (#136255)
fixes [`flexible_space_bar.dart': Failed assertion: line 475 pos 12: 'needsCompositing': is not true.` is thrown when scrolling down in the list and then up](https://github.com/flutter/flutter/issues/135698)
2023-10-11 07:19:30 +00:00
Polina Cherkasova
ad05949971
Fix flakiness: finalize dropped gestures in tests to release resources, and update doc-comment. (#136136) 2023-10-10 18:11:23 -07:00
Valentin Vignal
b989428fa2
Add SizeTransition.fixedCrossAxisSizeFactor (#134659)
Fixes https://github.com/flutter/flutter/issues/134654
2023-10-11 00:53:34 +00:00
Matan Lurey
f38244f0b5
Relaxed a test on Paint.toString() to ignore dither: .... (#136302)
Work towards https://github.com/flutter/flutter/issues/112498.

Behaviorally the same, except doesn't care if `dither: ...` shows up, or
not (it won't when https://github.com/flutter/flutter/issues/112498 is
fixed).
2023-10-10 17:50:35 -07:00
Greg Spencer
7e1d366a4d
Add key event handlers that happen before or after the focus traversal (#136280)
## Description

This adds a mechanism for listening to key events before or after focus traversal occurs.

It adds four methods to the public `FocusManager` API:

- `addEarlyKeyEventHandler` - Adds a handler that can handle events before they are given to the focus tree for handling.
- `removeEarlyKeyEventHandler` - Removes an early event handler.
- `addLateKeyEventHandler` - Adds a handler that can handle events if they have not been handled by anything in the focus tree.
- `removeLateKeyEventHandler` - Removes a late event handler.

This allows an app to get notified for a key anywhere, and prevent the focus tree from seeing that event if it handles it.

For the menu system, this allows it to eat an escape key press and close all the open menus.

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

## Tests
 - Added tests for new functionality.
2023-10-10 23:16:25 +00:00
Kostia Sokolovskyi
0a6947049b
TimePickerDialog should dispose created ChangeNotifiers. (#136261) 2023-10-10 11:05:26 -07:00
Kostia Sokolovskyi
5064f782c1
Cover more test/material tests with leak tracking. (#136093) 2023-10-10 10:05:51 -07:00
Kostia Sokolovskyi
5d9983a125
RenderAnnotatedRegion should dispose created layers. (#136086) 2023-10-10 08:32:01 -07:00
Polina Cherkasova
eec3f06090
TestClipPaintingContext should dispose ContainerLayer (#135949) 2023-10-10 08:19:50 -07:00
droidbg
67170b1254
[leak-tracking] Add leak tracking in test/painting #1 (#136167) 2023-10-09 13:10:07 -07:00
droidbg
3df6078bc4
[leak-tracking] Cover testwidgets with leak tracking in test/gestures (#136166) 2023-10-09 13:09:24 -07:00
Hassan
e127f7191b
[web] Fix page up page down home end shortcut behavior on web (#135454)
We delegate page up / page down actions to the browser. However, we don't let the browser scroll the underlying `<textarea>` - the framework handles scrolling, so page up/down don't end up doing anything. Since the framework handles scrolling for text inputs and textareas, we should let it also handle the actions for `page up`, `page down`, `home`, `end`, and their modifiers. 

fixes https://github.com/flutter/flutter/issues/121867
2023-10-09 17:50:54 +00:00
chunhtai
ff73448f33
Reland "Adds a parent scope TraversalEdgeBehavior and fixes modal rou… (#134554)
…… (#134550)"

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

This reverts commit 5900c4baa751aff8f05e820287a02b60cdd62dfa.

The internal test needs migration. cl/564746935

This is the same of original pr, no new change

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-10-09 09:10:23 -07:00
droidbg
f52fe4f7e5
[leak-tracking] Add leak tracking in test/painting #2 (#136169) 2023-10-09 07:22:29 -07:00
Taha Tesser
9ab091f92b
Update CircleAvatar & DataTable tests for Material 3 (#135901)
Updated unit tests for `CircleAvatar` & `DataTable` to have M2 and M3 versions.

More info in #127064
2023-10-09 10:05:28 +00:00
Bruno Leroux
a6d712497d
Update BottomSheet test for M3 + fix an issue in elevation resolution (#136071)
This PR updates unit tests from bottom sheet tests for M3 migration.

More info in https://github.com/flutter/flutter/issues/127064

It also contains in bottom_sheet.dart where a default value took precedence over a theme attribute.
2023-10-09 06:31:49 +00:00
Polina Cherkasova
74f8b4f777
Allow leaks around tap down/up, while flackiness is not fixed. (#136133) 2023-10-07 11:22:53 -07:00
LongCatIsLooong
ebe72d3f32
Call markNeedsPaint when adding overlayChild to Overlay (#135941)
Fixes https://github.com/flutter/flutter/issues/134656

`_skipMarkNeesLayout` was meant to only skip `markNeedsLayout` calls. Re-painting is still needed when a child gets added/removed from the `Overlay`.
2023-10-06 22:12:20 +00:00
Polina Cherkasova
f0970365ca
RenderEditable should dispose created layers. (#135942) 2023-10-06 12:30:20 -06:00
Kostia Sokolovskyi
d76e3abf10
Fix memory leaks in DateRangePickerDialog. (#136034)
This PR mainly fixes several memory leaks in the `DateRangePickerDialog`.

### Description
- Fixes https://github.com/flutter/flutter/issues/136033 by:
    1) adding a disposal of several `RestorableValue`;
    2) creating a separate `_DayItem` stateful widget that creates/updates/disposes internal `MaterialStatesController`.
- Marks https://github.com/flutter/flutter/issues/136036.

### Tests
- Updates `test/material/date_picker_theme_test.dart` to use `testWidgetsWithLeakTracking`;
- Updates `test/material/date_range_picker_test.dart` to use `testWidgetsWithLeakTracking`.
2023-10-06 11:26:06 +00:00
林洵锋
047bd6cebd
Fix the character field of RawKeyEvent is always null on iOS (#135100)
Fixes https://github.com/flutter/flutter/issues/133956
2023-10-03 05:26:41 +00:00
derdilla
1437aa2c7b
Cover some cupertino tests with leak tracking (#135230) 2023-10-02 17:44:50 -06:00
derdilla
397da0649a
leak track tab_scaffold_test.dart (#135309) 2023-10-02 17:39:47 -06:00
Kostia Sokolovskyi
ff68b62599
Fix a couple of CupertinoTextField tests to avoid leak-tracking test failures. (#135851) 2023-10-02 15:29:37 -06:00
Mitchell Goodwin
57ed724177
Update dialog tests for Material3 (#135775)
Separates the tests for the Material dialog into Material3 and Material2 versions.

More info in #127064
2023-10-02 11:03:18 +00:00
derdilla
783672588b
Test cover cupertino text field for memory leaks. (#135804) 2023-10-01 19:41:59 -07:00
Kostia Sokolovskyi
cfe7afdc50
Fix memory leaks in WidgetInspector and WidgetInspectorService. (#135828) 2023-10-01 19:41:46 -07:00
derdilla
71acf24201
leak track page_test.dart (#135352) 2023-10-01 16:45:02 -07:00
derdilla
994f71c267
Leak track cupertino widgets (#135353) 2023-10-01 16:42:45 -07:00
Kostia Sokolovskyi
95eae5f967
Cover more test/widgets tests with leak tracking #12. (#135385) 2023-09-29 17:47:04 -07:00
Kostia Sokolovskyi
fdde24195f
DraggableScrollableController should dispatch creation in constructor. (#135423) 2023-09-29 17:45:35 -07:00