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
c62d103b
Unverified
Commit
c62d103b
authored
Apr 13, 2022
by
Jason Simmons
Committed by
GitHub
Apr 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always finish the timeline event logged by Element.inflateWidget (#101794)
parent
fe6d09a9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
25 deletions
+104
-25
inflate_widget_update_test.dart
dev/tracing_tests/test/inflate_widget_update_test.dart
+77
-0
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+27
-25
No files found.
dev/tracing_tests/test/inflate_widget_update_test.dart
0 → 100644
View file @
c62d103b
// 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/scheduler.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'common.dart'
;
void
main
(
)
{
WidgetsFlutterBinding
.
ensureInitialized
();
initTimelineTests
();
test
(
'Widgets with updated keys produce well formed timelines'
,
()
async
{
await
runFrame
(()
{
runApp
(
const
TestRoot
());
});
await
SchedulerBinding
.
instance
.
endOfFrame
;
debugProfileBuildsEnabled
=
true
;
await
runFrame
(()
{
TestRoot
.
state
.
updateKey
();
});
int
buildCount
=
0
;
for
(
final
TimelineEvent
event
in
await
fetchTimelineEvents
())
{
if
(
event
.
json
![
'name'
]
==
'BUILD'
)
{
final
String
ph
=
event
.
json
![
'ph'
]
as
String
;
if
(
ph
==
'B'
)
{
buildCount
++;
}
else
if
(
ph
==
'E'
)
{
buildCount
--;
}
}
}
expect
(
buildCount
,
0
);
debugProfileBuildsEnabled
=
false
;
},
skip:
isBrowser
);
// [intended] uses dart:isolate and io.
}
class
TestRoot
extends
StatefulWidget
{
const
TestRoot
({
super
.
key
});
static
late
TestRootState
state
;
@override
State
<
TestRoot
>
createState
()
=>
TestRootState
();
}
class
TestRootState
extends
State
<
TestRoot
>
{
final
Key
_globalKey
=
GlobalKey
();
Key
_localKey
=
UniqueKey
();
@override
void
initState
()
{
super
.
initState
();
TestRoot
.
state
=
this
;
}
void
updateKey
()
{
setState
(()
{
_localKey
=
UniqueKey
();
});
}
@override
Widget
build
(
BuildContext
context
)
{
return
Center
(
key:
_localKey
,
child:
SizedBox
(
key:
_globalKey
,
width:
100
,
height:
100
,
),
);
}
}
packages/flutter/lib/src/widgets/framework.dart
View file @
c62d103b
...
...
@@ -3792,6 +3792,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
);
}
try
{
final
Key
?
key
=
newWidget
.
key
;
if
(
key
is
GlobalKey
)
{
final
Element
?
newChild
=
_retakeInactiveElement
(
key
,
newWidget
);
...
...
@@ -3815,10 +3816,11 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
newChild
.
mount
(
this
,
newSlot
);
assert
(
newChild
.
_lifecycleState
==
_ElementLifecycle
.
active
);
return
newChild
;
}
finally
{
if
(
isTimelineTracked
)
Timeline
.
finishSync
();
return
newChild
;
}
}
void
_debugCheckForCycles
(
Element
newChild
)
{
...
...
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