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
610dc170
Unverified
Commit
610dc170
authored
May 13, 2020
by
snyiuan
Committed by
GitHub
May 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setState() will call scheduleFrame() in post-frame callback now. (#56968)
parent
3ccb160d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
semantics_debugger.dart
packages/flutter/lib/src/widgets/semantics_debugger.dart
+1
-6
semantics_debugger_test.dart
packages/flutter/test/widgets/semantics_debugger_test.dart
+10
-0
No files found.
packages/flutter/lib/src/widgets/semantics_debugger.dart
View file @
610dc170
...
...
@@ -83,11 +83,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> with WidgetsBindi
SchedulerBinding
.
instance
.
addPostFrameCallback
((
Duration
timeStamp
)
{
// Semantic information are only available at the end of a frame and our
// only chance to paint them on the screen is the next frame. To achieve
// this, we call setState() in a post-frame callback. THIS PATTERN SHOULD
// NOT BE COPIED. Calling setState() in a post-frame callback is a bad
// idea as it will not schedule a frame and your app may be lagging behind
// by one frame. We manually call scheduleFrame() to force a frame and
// ensure that the semantic information are always painted on the screen.
// this, we call setState() in a post-frame callback.
if
(
mounted
)
{
// If we got disposed this frame, we will still get an update,
// because the inactive list is flushed after the semantics updates
...
...
@@ -95,7 +91,6 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> with WidgetsBindi
setState
(()
{
// The generation of the _SemanticsDebuggerListener has changed.
});
SchedulerBinding
.
instance
.
scheduleFrame
();
}
});
}
...
...
packages/flutter/test/widgets/semantics_debugger_test.dart
View file @
610dc170
...
...
@@ -10,6 +10,16 @@ import 'package:flutter/rendering.dart';
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'SemanticsDebugger will schedule a frame'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
SemanticsDebugger
(
child:
Container
(),
),
);
expect
(
tester
.
binding
.
hasScheduledFrame
,
isTrue
);
});
testWidgets
(
'SemanticsDebugger smoke test'
,
(
WidgetTester
tester
)
async
{
// This is a smoketest to verify that adding a debugger doesn't crash.
...
...
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