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
28ca7bd7
Unverified
Commit
28ca7bd7
authored
Jan 24, 2022
by
chunhtai
Committed by
GitHub
Jan 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow current leader of layerlink to detach before the previous leade… (#96810)
parent
62e74561
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
6 deletions
+88
-6
layer.dart
packages/flutter/lib/src/rendering/layer.dart
+2
-6
layers_test.dart
packages/flutter/test/rendering/layers_test.dart
+13
-0
framework_test.dart
packages/flutter/test/widgets/framework_test.dart
+73
-0
No files found.
packages/flutter/lib/src/rendering/layer.dart
View file @
28ca7bd7
...
...
@@ -2118,8 +2118,8 @@ class LayerLink {
assert
((){
if
(
_leader
!=
null
)
{
_debugPreviousLeaders
??=
<
LeaderLayer
>{};
_debugPreviousLeaders
!.
add
(
_leader
!);
_debugScheduleLeadersCleanUpCheck
();
return
_debugPreviousLeaders
!.
add
(
_leader
!);
}
return
true
;
}());
...
...
@@ -2127,14 +2127,10 @@ class LayerLink {
}
void
_unregisterLeader
(
LeaderLayer
leader
)
{
assert
(
_leader
!=
null
);
if
(
_leader
==
leader
)
{
_leader
=
null
;
}
else
{
assert
((){
_debugPreviousLeaders
!.
remove
(
leader
);
return
true
;
}());
assert
(
_debugPreviousLeaders
!.
remove
(
leader
));
}
}
...
...
packages/flutter/test/rendering/layers_test.dart
View file @
28ca7bd7
...
...
@@ -176,6 +176,19 @@ void main() {
expect
(
leaderLayer
.
link
,
link2
);
});
test
(
'layer link attach/detach order should not crash app.'
,
()
{
renderer
;
final
LayerLink
link
=
LayerLink
();
final
LeaderLayer
leaderLayer1
=
LeaderLayer
(
link:
link
);
final
LeaderLayer
leaderLayer2
=
LeaderLayer
(
link:
link
);
final
RenderView
view
=
RenderView
(
configuration:
const
ViewConfiguration
(),
window:
window
);
leaderLayer1
.
attach
(
view
);
leaderLayer2
.
attach
(
view
);
leaderLayer2
.
detach
();
leaderLayer1
.
detach
();
expect
(
link
.
leader
,
isNull
);
});
test
(
'leader layers not dirty when connected to follower layer'
,
()
{
final
ContainerLayer
root
=
ContainerLayer
()..
attach
(
Object
());
...
...
packages/flutter/test/widgets/framework_test.dart
View file @
28ca7bd7
...
...
@@ -5,6 +5,7 @@
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -1587,6 +1588,28 @@ void main() {
expect
(()
=>
element
.
widget
,
throwsA
(
isA
<
TypeError
>()));
});
testWidgets
(
'LayerLink can be swapped between parent and child container layers'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/96959.
final
LayerLink
link
=
LayerLink
();
await
tester
.
pumpWidget
(
_TestLeaderLayerWidget
(
link:
link
,
child:
const
_TestLeaderLayerWidget
(
child:
Placeholder
(),
)
));
expect
(
tester
.
takeException
(),
isNull
);
// Swaps the layer link.
await
tester
.
pumpWidget
(
_TestLeaderLayerWidget
(
child:
_TestLeaderLayerWidget
(
link:
link
,
child:
const
Placeholder
(),
),
));
expect
(
tester
.
takeException
(),
isNull
);
});
testWidgets
(
'Deactivate and activate are called correctly'
,
(
WidgetTester
tester
)
async
{
final
List
<
String
>
states
=
<
String
>[];
Widget
build
([
Key
?
key
])
{
...
...
@@ -2031,3 +2054,53 @@ class _EmptyElement extends Element {
@override
void
performRebuild
()
{}
}
class
_TestLeaderLayerWidget
extends
SingleChildRenderObjectWidget
{
const
_TestLeaderLayerWidget
({
Key
?
key
,
this
.
link
,
Widget
?
child
,
})
:
super
(
key:
key
,
child:
child
);
final
LayerLink
?
link
;
@override
_RenderTestLeaderLayerWidget
createRenderObject
(
BuildContext
context
)
{
return
_RenderTestLeaderLayerWidget
(
link:
link
,
);
}
@override
void
updateRenderObject
(
BuildContext
context
,
_RenderTestLeaderLayerWidget
renderObject
)
{
renderObject
.
link
=
link
;
}
}
class
_RenderTestLeaderLayerWidget
extends
RenderProxyBox
{
_RenderTestLeaderLayerWidget
({
LayerLink
?
link
,
RenderBox
?
child
,
})
:
_link
=
link
,
super
(
child
);
LayerLink
?
get
link
=>
_link
;
LayerLink
?
_link
;
set
link
(
LayerLink
?
value
)
{
if
(
_link
==
value
)
{
return
;
}
_link
=
value
;
markNeedsPaint
();
}
@override
bool
get
isRepaintBoundary
=>
true
;
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
super
.
paint
(
context
,
offset
);
if
(
_link
!=
null
)
{
context
.
pushLayer
(
LeaderLayer
(
link:
_link
!,
offset:
offset
),(
_
,
__
){},
Offset
.
zero
);
}
}
}
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