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
5177a37f
Unverified
Commit
5177a37f
authored
Aug 08, 2018
by
Jonah Williams
Committed by
GitHub
Aug 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove periodic timer from Scaffold snackbar logic (#20317)
parent
db58c665
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+20
-2
No files found.
packages/flutter/lib/src/material/scaffold.dart
View file @
5177a37f
...
...
@@ -1075,6 +1075,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
final
Queue
<
ScaffoldFeatureController
<
SnackBar
,
SnackBarClosedReason
>>
_snackBars
=
new
Queue
<
ScaffoldFeatureController
<
SnackBar
,
SnackBarClosedReason
>>();
AnimationController
_snackBarController
;
Timer
_snackBarTimer
;
bool
_accessibleNavigation
;
/// Shows a [SnackBar] at the bottom of the scaffold.
///
...
...
@@ -1396,6 +1397,23 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
super
.
didUpdateWidget
(
oldWidget
);
}
@override
void
didChangeDependencies
()
{
final
MediaQueryData
mediaQuery
=
MediaQuery
.
of
(
context
);
// If we transition from accessible navigation to non-accessible navigation
// and there is a SnackBar that would have timed out that has already
// completed its timer, dismiss that SnackBar. If the timer hasn't finished
// yet, let it timeout as normal.
if
(
_accessibleNavigation
==
true
&&
!
mediaQuery
.
accessibleNavigation
&&
_snackBarTimer
!=
null
&&
!
_snackBarTimer
.
isActive
)
{
hideCurrentSnackBar
(
reason:
SnackBarClosedReason
.
timeout
);
}
_accessibleNavigation
=
mediaQuery
.
accessibleNavigation
;
super
.
didChangeDependencies
();
}
@override
void
dispose
()
{
_snackBarController
?.
dispose
();
...
...
@@ -1482,20 +1500,20 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
final
MediaQueryData
mediaQuery
=
MediaQuery
.
of
(
context
);
final
ThemeData
themeData
=
Theme
.
of
(
context
);
final
TextDirection
textDirection
=
Directionality
.
of
(
context
);
_accessibleNavigation
=
mediaQuery
.
accessibleNavigation
;
if
(
_snackBars
.
isNotEmpty
)
{
final
ModalRoute
<
dynamic
>
route
=
ModalRoute
.
of
(
context
);
if
(
route
==
null
||
route
.
isCurrent
)
{
if
(
_snackBarController
.
isCompleted
&&
_snackBarTimer
==
null
)
{
final
SnackBar
snackBar
=
_snackBars
.
first
.
_widget
;
_snackBarTimer
=
new
Timer
.
periodic
(
snackBar
.
duration
,
(
Timer
timer
)
{
_snackBarTimer
=
new
Timer
(
snackBar
.
duration
,
(
)
{
assert
(
_snackBarController
.
status
==
AnimationStatus
.
forward
||
_snackBarController
.
status
==
AnimationStatus
.
completed
);
// Look up MediaQuery again in case the setting changed.
final
MediaQueryData
mediaQuery
=
MediaQuery
.
of
(
context
);
if
(
mediaQuery
.
accessibleNavigation
&&
snackBar
.
action
!=
null
)
return
;
timer
.
cancel
();
hideCurrentSnackBar
(
reason:
SnackBarClosedReason
.
timeout
);
});
}
...
...
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