Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
453a04d9
Unverified
Commit
453a04d9
authored
Mar 25, 2024
by
Kostia Sokolovskyi
Committed by
GitHub
Mar 25, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TwoDimensionalChildDelegate should dispatch creation and disposal events (#145684)
parent
47bfa827
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
13 deletions
+62
-13
scroll_delegate.dart
packages/flutter/lib/src/widgets/scroll_delegate.dart
+7
-0
ensure_visible_test.dart
packages/flutter/test/widgets/ensure_visible_test.dart
+1
-5
scroll_delegate_test.dart
packages/flutter/test/widgets/scroll_delegate_test.dart
+29
-0
two_dimensional_scroll_view_test.dart
...lutter/test/widgets/two_dimensional_scroll_view_test.dart
+24
-8
two_dimensional_viewport_test.dart
...s/flutter/test/widgets/two_dimensional_viewport_test.dart
+1
-0
No files found.
packages/flutter/lib/src/widgets/scroll_delegate.dart
View file @
453a04d9
...
...
@@ -885,6 +885,13 @@ Widget _createErrorWidget(Object exception, StackTrace stackTrace) {
/// * [TwoDimensionalChildListDelegate], an concrete subclass of this that
/// uses a two dimensional array to layout children.
abstract
class
TwoDimensionalChildDelegate
extends
ChangeNotifier
{
/// Creates a delegate that supplies children for scrolling in two dimensions.
TwoDimensionalChildDelegate
()
{
if
(
kFlutterMemoryAllocationsEnabled
)
{
ChangeNotifier
.
maybeDispatchObjectCreation
(
this
);
}
}
/// Returns the child with the given [ChildVicinity], which is described in
/// terms of x and y indices.
///
...
...
packages/flutter/test/widgets/ensure_visible_test.dart
View file @
453a04d9
...
...
@@ -7,7 +7,6 @@ import 'dart:math' as math;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
import
'two_dimensional_utils.dart'
;
...
...
@@ -1063,10 +1062,7 @@ void main() {
return
tester
.
element
(
findKey
(
vicinity
));
}
testWidgets
(
'Axis.vertical'
,
// TODO(polina-c): RenderTwoDimensionalViewport should dispose _delegate https://github.com/flutter/flutter/issues/145628 [leaks-to-clean]
experimentalLeakTesting:
LeakTesting
.
settings
.
withIgnoredAll
(),
(
WidgetTester
tester
)
async
{
testWidgets
(
'Axis.vertical'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
simpleBuilderTest
(
useCacheExtent:
true
));
Scrollable
.
ensureVisible
(
findContext
(
...
...
packages/flutter/test/widgets/scroll_delegate_test.dart
0 → 100644
View file @
453a04d9
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
void
main
(
)
{
test
(
'TwoDimensionalChildBuilderDelegate dispatches memory events'
,
()
async
{
await
expectLater
(
await
memoryEvents
(
()
=>
TwoDimensionalChildBuilderDelegate
(
builder:
(
_
,
__
)
=>
null
).
dispose
(),
TwoDimensionalChildBuilderDelegate
,
),
areCreateAndDispose
,
);
});
test
(
'TwoDimensionalChildListDelegate dispatches memory events'
,
()
async
{
await
expectLater
(
await
memoryEvents
(
()
=>
TwoDimensionalChildListDelegate
(
children:
<
List
<
Widget
>>[]).
dispose
(),
TwoDimensionalChildListDelegate
,
),
areCreateAndDispose
,
);
});
}
packages/flutter/test/widgets/two_dimensional_scroll_view_test.dart
View file @
453a04d9
...
...
@@ -360,6 +360,8 @@ void main() {
addTearDown
(
verticalController
.
dispose
);
final
ScrollController
horizontalController
=
ScrollController
();
addTearDown
(
horizontalController
.
dispose
);
late
final
TwoDimensionalChildBuilderDelegate
delegate
;
addTearDown
(()
=>
delegate
.
dispose
());
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -368,7 +370,7 @@ void main() {
verticalDetails:
ScrollableDetails
.
vertical
(
controller:
verticalController
),
horizontalDetails:
ScrollableDetails
.
horizontal
(
controller:
horizontalController
),
diagonalDragBehavior:
DiagonalDragBehavior
.
free
,
delegate:
TwoDimensionalChildBuilderDelegate
(
delegate:
delegate
=
TwoDimensionalChildBuilderDelegate
(
maxXIndex:
100
,
maxYIndex:
100
,
builder:
(
BuildContext
context
,
ChildVicinity
vicinity
)
{
...
...
@@ -503,6 +505,8 @@ void main() {
addTearDown
(
verticalController
.
dispose
);
final
ScrollController
horizontalController
=
ScrollController
();
addTearDown
(
horizontalController
.
dispose
);
late
final
TwoDimensionalChildBuilderDelegate
delegate
;
addTearDown
(()
=>
delegate
.
dispose
());
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -511,7 +515,7 @@ void main() {
verticalDetails:
ScrollableDetails
.
vertical
(
controller:
verticalController
),
horizontalDetails:
ScrollableDetails
.
horizontal
(
controller:
horizontalController
),
diagonalDragBehavior:
DiagonalDragBehavior
.
free
,
delegate:
TwoDimensionalChildBuilderDelegate
(
delegate:
delegate
=
TwoDimensionalChildBuilderDelegate
(
maxXIndex:
100
,
maxYIndex:
100
,
builder:
(
BuildContext
context
,
ChildVicinity
vicinity
)
{
...
...
@@ -588,6 +592,8 @@ void main() {
addTearDown
(
verticalController
.
dispose
);
final
ScrollController
horizontalController
=
ScrollController
();
addTearDown
(
horizontalController
.
dispose
);
late
final
TwoDimensionalChildBuilderDelegate
delegate
;
addTearDown
(()
=>
delegate
.
dispose
());
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -596,7 +602,7 @@ void main() {
verticalDetails:
ScrollableDetails
.
vertical
(
controller:
verticalController
),
horizontalDetails:
ScrollableDetails
.
horizontal
(
controller:
horizontalController
),
diagonalDragBehavior:
DiagonalDragBehavior
.
free
,
delegate:
TwoDimensionalChildBuilderDelegate
(
delegate:
delegate
=
TwoDimensionalChildBuilderDelegate
(
maxXIndex:
20
,
maxYIndex:
1
,
builder:
_testChildBuilder
,
...
...
@@ -636,6 +642,8 @@ void main() {
addTearDown
(
verticalController
.
dispose
);
final
ScrollController
horizontalController
=
ScrollController
();
addTearDown
(
horizontalController
.
dispose
);
late
final
TwoDimensionalChildBuilderDelegate
delegate
;
addTearDown
(()
=>
delegate
.
dispose
());
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -644,7 +652,7 @@ void main() {
verticalDetails:
ScrollableDetails
.
vertical
(
controller:
verticalController
),
horizontalDetails:
ScrollableDetails
.
horizontal
(
controller:
horizontalController
),
diagonalDragBehavior:
DiagonalDragBehavior
.
weightedEvent
,
delegate:
TwoDimensionalChildBuilderDelegate
(
delegate:
delegate
=
TwoDimensionalChildBuilderDelegate
(
maxXIndex:
20
,
maxYIndex:
1
,
builder:
_testChildBuilder
,
...
...
@@ -684,6 +692,8 @@ void main() {
addTearDown
(
verticalController
.
dispose
);
final
ScrollController
horizontalController
=
ScrollController
();
addTearDown
(
horizontalController
.
dispose
);
late
final
TwoDimensionalChildBuilderDelegate
delegate
;
addTearDown
(()
=>
delegate
.
dispose
());
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -692,7 +702,7 @@ void main() {
verticalDetails:
ScrollableDetails
.
vertical
(
controller:
verticalController
),
horizontalDetails:
ScrollableDetails
.
horizontal
(
controller:
horizontalController
),
diagonalDragBehavior:
DiagonalDragBehavior
.
weightedContinuous
,
delegate:
TwoDimensionalChildBuilderDelegate
(
delegate:
delegate
=
TwoDimensionalChildBuilderDelegate
(
maxXIndex:
20
,
maxYIndex:
1
,
builder:
_testChildBuilder
,
...
...
@@ -734,6 +744,8 @@ void main() {
addTearDown
(
verticalController
.
dispose
);
final
ScrollController
horizontalController
=
ScrollController
();
addTearDown
(
horizontalController
.
dispose
);
late
final
TwoDimensionalChildBuilderDelegate
delegate
;
addTearDown
(()
=>
delegate
.
dispose
());
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -742,7 +754,7 @@ void main() {
verticalDetails:
ScrollableDetails
.
vertical
(
controller:
verticalController
),
horizontalDetails:
ScrollableDetails
.
horizontal
(
controller:
horizontalController
),
diagonalDragBehavior:
DiagonalDragBehavior
.
free
,
delegate:
TwoDimensionalChildBuilderDelegate
(
delegate:
delegate
=
TwoDimensionalChildBuilderDelegate
(
maxXIndex:
1
,
maxYIndex:
20
,
builder:
_testChildBuilder
,
...
...
@@ -782,6 +794,8 @@ void main() {
addTearDown
(
verticalController
.
dispose
);
final
ScrollController
horizontalController
=
ScrollController
();
addTearDown
(
horizontalController
.
dispose
);
late
final
TwoDimensionalChildBuilderDelegate
delegate
;
addTearDown
(()
=>
delegate
.
dispose
());
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -790,7 +804,7 @@ void main() {
verticalDetails:
ScrollableDetails
.
vertical
(
controller:
verticalController
),
horizontalDetails:
ScrollableDetails
.
horizontal
(
controller:
horizontalController
),
diagonalDragBehavior:
DiagonalDragBehavior
.
weightedEvent
,
delegate:
TwoDimensionalChildBuilderDelegate
(
delegate:
delegate
=
TwoDimensionalChildBuilderDelegate
(
maxXIndex:
1
,
maxYIndex:
20
,
builder:
_testChildBuilder
,
...
...
@@ -830,6 +844,8 @@ void main() {
addTearDown
(
verticalController
.
dispose
);
final
ScrollController
horizontalController
=
ScrollController
();
addTearDown
(
horizontalController
.
dispose
);
late
final
TwoDimensionalChildBuilderDelegate
delegate
;
addTearDown
(()
=>
delegate
.
dispose
());
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -838,7 +854,7 @@ void main() {
verticalDetails:
ScrollableDetails
.
vertical
(
controller:
verticalController
),
horizontalDetails:
ScrollableDetails
.
horizontal
(
controller:
horizontalController
),
diagonalDragBehavior:
DiagonalDragBehavior
.
weightedContinuous
,
delegate:
TwoDimensionalChildBuilderDelegate
(
delegate:
delegate
=
TwoDimensionalChildBuilderDelegate
(
maxXIndex:
1
,
maxYIndex:
20
,
builder:
_testChildBuilder
,
...
...
packages/flutter/test/widgets/two_dimensional_viewport_test.dart
View file @
453a04d9
...
...
@@ -335,6 +335,7 @@ void main() {
);
}
);
addTearDown
(
builderDelegate
.
dispose
);
await
tester
.
pumpWidget
(
simpleBuilderTest
(
delegate:
builderDelegate
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment