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
9e658bc3
Unverified
Commit
9e658bc3
authored
Jul 21, 2020
by
Alexandre Ardhuin
Committed by
GitHub
Jul 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate scheduler to nullsafety (#61570)
parent
fdf87edd
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
74 deletions
+63
-74
scheduler.dart
packages/flutter/lib/scheduler.dart
+0
-2
binding.dart
packages/flutter/lib/src/scheduler/binding.dart
+34
-37
debug.dart
packages/flutter/lib/src/scheduler/debug.dart
+0
-2
priority.dart
packages/flutter/lib/src/scheduler/priority.dart
+0
-2
ticker.dart
packages/flutter/lib/src/scheduler/ticker.dart
+29
-31
No files found.
packages/flutter/lib/scheduler.dart
View file @
9e658bc3
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
/// The Flutter Scheduler library.
/// The Flutter Scheduler library.
///
///
/// To use, import `package:flutter/scheduler.dart`.
/// To use, import `package:flutter/scheduler.dart`.
...
...
packages/flutter/lib/src/scheduler/binding.dart
View file @
9e658bc3
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/scheduler/debug.dart
View file @
9e658bc3
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
// Any changes to this file should be reflected in the debugAssertAllSchedulerVarsUnset()
// Any changes to this file should be reflected in the debugAssertAllSchedulerVarsUnset()
...
...
packages/flutter/lib/src/scheduler/priority.dart
View file @
9e658bc3
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
/// A task priority, as passed to [SchedulerBinding.scheduleTask].
/// A task priority, as passed to [SchedulerBinding.scheduleTask].
...
...
packages/flutter/lib/src/scheduler/ticker.dart
View file @
9e658bc3
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
...
@@ -71,7 +69,7 @@ class Ticker {
...
@@ -71,7 +69,7 @@ class Ticker {
}());
}());
}
}
TickerFuture
_future
;
TickerFuture
?
_future
;
/// Whether this ticker has been silenced.
/// Whether this ticker has been silenced.
///
///
...
@@ -115,9 +113,9 @@ class Ticker {
...
@@ -115,9 +113,9 @@ class Ticker {
return
false
;
return
false
;
if
(
muted
)
if
(
muted
)
return
false
;
return
false
;
if
(
SchedulerBinding
.
instance
.
framesEnabled
)
if
(
SchedulerBinding
.
instance
!
.
framesEnabled
)
return
true
;
return
true
;
if
(
SchedulerBinding
.
instance
.
schedulerPhase
!=
SchedulerPhase
.
idle
)
if
(
SchedulerBinding
.
instance
!
.
schedulerPhase
!=
SchedulerPhase
.
idle
)
return
true
;
// for example, we might be in a warm-up frame or forced frame
return
true
;
// for example, we might be in a warm-up frame or forced frame
return
false
;
return
false
;
}
}
...
@@ -130,7 +128,7 @@ class Ticker {
...
@@ -130,7 +128,7 @@ class Ticker {
/// [isTicking].
/// [isTicking].
bool
get
isActive
=>
_future
!=
null
;
bool
get
isActive
=>
_future
!=
null
;
Duration
_startTime
;
Duration
?
_startTime
;
/// Starts the clock for this [Ticker]. If the ticker is not [muted], then this
/// Starts the clock for this [Ticker]. If the ticker is not [muted], then this
/// also starts calling the ticker's callback once per animation frame.
/// also starts calling the ticker's callback once per animation frame.
...
@@ -163,10 +161,10 @@ class Ticker {
...
@@ -163,10 +161,10 @@ class Ticker {
if
(
shouldScheduleTick
)
{
if
(
shouldScheduleTick
)
{
scheduleTick
();
scheduleTick
();
}
}
if
(
SchedulerBinding
.
instance
.
schedulerPhase
.
index
>
SchedulerPhase
.
idle
.
index
&&
if
(
SchedulerBinding
.
instance
!
.
schedulerPhase
.
index
>
SchedulerPhase
.
idle
.
index
&&
SchedulerBinding
.
instance
.
schedulerPhase
.
index
<
SchedulerPhase
.
postFrameCallbacks
.
index
)
SchedulerBinding
.
instance
!
.
schedulerPhase
.
index
<
SchedulerPhase
.
postFrameCallbacks
.
index
)
_startTime
=
SchedulerBinding
.
instance
.
currentFrameTimeStamp
;
_startTime
=
SchedulerBinding
.
instance
!
.
currentFrameTimeStamp
;
return
_future
;
return
_future
!
;
}
}
/// Adds a debug representation of a [Ticker] optimized for including in error
/// Adds a debug representation of a [Ticker] optimized for including in error
...
@@ -197,7 +195,7 @@ class Ticker {
...
@@ -197,7 +195,7 @@ class Ticker {
// We take the _future into a local variable so that isTicking is false
// We take the _future into a local variable so that isTicking is false
// when we actually complete the future (isTicking uses _future to
// when we actually complete the future (isTicking uses _future to
// determine its state).
// determine its state).
final
TickerFuture
localFuture
=
_future
;
final
TickerFuture
localFuture
=
_future
!
;
_future
=
null
;
_future
=
null
;
_startTime
=
null
;
_startTime
=
null
;
assert
(!
isActive
);
assert
(!
isActive
);
...
@@ -213,7 +211,7 @@ class Ticker {
...
@@ -213,7 +211,7 @@ class Ticker {
final
TickerCallback
_onTick
;
final
TickerCallback
_onTick
;
int
_animationId
;
int
?
_animationId
;
/// Whether this [Ticker] has already scheduled a frame callback.
/// Whether this [Ticker] has already scheduled a frame callback.
@protected
@protected
...
@@ -237,7 +235,7 @@ class Ticker {
...
@@ -237,7 +235,7 @@ class Ticker {
_animationId
=
null
;
_animationId
=
null
;
_startTime
??=
timeStamp
;
_startTime
??=
timeStamp
;
_onTick
(
timeStamp
-
_startTime
);
_onTick
(
timeStamp
-
_startTime
!
);
// The onTick callback may have scheduled another tick already, for
// The onTick callback may have scheduled another tick already, for
// example by calling stop then start again.
// example by calling stop then start again.
...
@@ -252,7 +250,7 @@ class Ticker {
...
@@ -252,7 +250,7 @@ class Ticker {
void
scheduleTick
({
bool
rescheduling
=
false
})
{
void
scheduleTick
({
bool
rescheduling
=
false
})
{
assert
(!
scheduled
);
assert
(!
scheduled
);
assert
(
shouldScheduleTick
);
assert
(
shouldScheduleTick
);
_animationId
=
SchedulerBinding
.
instance
.
scheduleFrameCallback
(
_tick
,
rescheduling:
rescheduling
);
_animationId
=
SchedulerBinding
.
instance
!
.
scheduleFrameCallback
(
_tick
,
rescheduling:
rescheduling
);
}
}
/// Cancels the frame callback that was requested by [scheduleTick], if any.
/// Cancels the frame callback that was requested by [scheduleTick], if any.
...
@@ -264,7 +262,7 @@ class Ticker {
...
@@ -264,7 +262,7 @@ class Ticker {
@protected
@protected
void
unscheduleTick
()
{
void
unscheduleTick
()
{
if
(
scheduled
)
{
if
(
scheduled
)
{
SchedulerBinding
.
instance
.
cancelFrameCallbackWithId
(
_animationId
);
SchedulerBinding
.
instance
!.
cancelFrameCallbackWithId
(
_animationId
!
);
_animationId
=
null
;
_animationId
=
null
;
}
}
assert
(!
shouldScheduleTick
);
assert
(!
shouldScheduleTick
);
...
@@ -301,7 +299,7 @@ class Ticker {
...
@@ -301,7 +299,7 @@ class Ticker {
@mustCallSuper
@mustCallSuper
void
dispose
()
{
void
dispose
()
{
if
(
_future
!=
null
)
{
if
(
_future
!=
null
)
{
final
TickerFuture
localFuture
=
_future
;
final
TickerFuture
localFuture
=
_future
!
;
_future
=
null
;
_future
=
null
;
assert
(!
isActive
);
assert
(!
isActive
);
unscheduleTick
();
unscheduleTick
();
...
@@ -319,8 +317,8 @@ class Ticker {
...
@@ -319,8 +317,8 @@ class Ticker {
/// An optional label can be provided for debugging purposes.
/// An optional label can be provided for debugging purposes.
///
///
/// This label will appear in the [toString] output in debug builds.
/// This label will appear in the [toString] output in debug builds.
final
String
debugLabel
;
final
String
?
debugLabel
;
StackTrace
_debugCreationStack
;
late
StackTrace
_debugCreationStack
;
@override
@override
String
toString
({
bool
debugIncludeStack
=
false
})
{
String
toString
({
bool
debugIncludeStack
=
false
})
{
...
@@ -374,14 +372,14 @@ class TickerFuture implements Future<void> {
...
@@ -374,14 +372,14 @@ class TickerFuture implements Future<void> {
}
}
final
Completer
<
void
>
_primaryCompleter
=
Completer
<
void
>();
final
Completer
<
void
>
_primaryCompleter
=
Completer
<
void
>();
Completer
<
void
>
_secondaryCompleter
;
Completer
<
void
>
?
_secondaryCompleter
;
bool
_completed
;
// null means unresolved, true means complete, false means canceled
bool
?
_completed
;
// null means unresolved, true means complete, false means canceled
void
_complete
()
{
void
_complete
()
{
assert
(
_completed
==
null
);
assert
(
_completed
==
null
);
_completed
=
true
;
_completed
=
true
;
_primaryCompleter
.
complete
(
null
);
_primaryCompleter
.
complete
();
_secondaryCompleter
?.
complete
(
null
);
_secondaryCompleter
?.
complete
();
}
}
void
_cancel
(
Ticker
ticker
)
{
void
_cancel
(
Ticker
ticker
)
{
...
@@ -415,14 +413,14 @@ class TickerFuture implements Future<void> {
...
@@ -415,14 +413,14 @@ class TickerFuture implements Future<void> {
if
(
_secondaryCompleter
==
null
)
{
if
(
_secondaryCompleter
==
null
)
{
_secondaryCompleter
=
Completer
<
void
>();
_secondaryCompleter
=
Completer
<
void
>();
if
(
_completed
!=
null
)
{
if
(
_completed
!=
null
)
{
if
(
_completed
)
{
if
(
_completed
!
)
{
_secondaryCompleter
.
complete
();
_secondaryCompleter
!
.
complete
();
}
else
{
}
else
{
_secondaryCompleter
.
completeError
(
const
TickerCanceled
());
_secondaryCompleter
!
.
completeError
(
const
TickerCanceled
());
}
}
}
}
}
}
return
_secondaryCompleter
.
future
;
return
_secondaryCompleter
!
.
future
;
}
}
@override
@override
...
@@ -431,17 +429,17 @@ class TickerFuture implements Future<void> {
...
@@ -431,17 +429,17 @@ class TickerFuture implements Future<void> {
}
}
@override
@override
Future
<
void
>
catchError
(
Function
onError
,
{
bool
test
(
dynamic
error
)
})
{
Future
<
void
>
catchError
(
Function
onError
,
{
bool
Function
(
Object
)?
test
})
{
return
_primaryCompleter
.
future
.
catchError
(
onError
,
test:
test
);
return
_primaryCompleter
.
future
.
catchError
(
onError
,
test:
test
);
}
}
@override
@override
Future
<
R
>
then
<
R
>(
FutureOr
<
R
>
onValue
(
void
value
),
{
Function
onError
})
{
Future
<
R
>
then
<
R
>(
FutureOr
<
R
>
onValue
(
void
value
),
{
Function
?
onError
})
{
return
_primaryCompleter
.
future
.
then
<
R
>(
onValue
,
onError:
onError
);
return
_primaryCompleter
.
future
.
then
<
R
>(
onValue
,
onError:
onError
);
}
}
@override
@override
Future
<
void
>
timeout
(
Duration
timeLimit
,
{
dynamic
onTimeout
()
})
{
Future
<
void
>
timeout
(
Duration
timeLimit
,
{
FutureOr
<
void
>
Function
()?
onTimeout
})
{
return
_primaryCompleter
.
future
.
timeout
(
timeLimit
,
onTimeout:
onTimeout
);
return
_primaryCompleter
.
future
.
timeout
(
timeLimit
,
onTimeout:
onTimeout
);
}
}
...
@@ -451,7 +449,7 @@ class TickerFuture implements Future<void> {
...
@@ -451,7 +449,7 @@ class TickerFuture implements Future<void> {
}
}
@override
@override
String
toString
()
=>
'
${describeIdentity(this)}
(
${ _completed == null ? "active" : _completed ? "complete" : "canceled" }
)'
;
String
toString
()
=>
'
${describeIdentity(this)}
(
${ _completed == null ? "active" : _completed
!
? "complete" : "canceled" }
)'
;
}
}
/// Exception thrown by [Ticker] objects on the [TickerFuture.orCancel] future
/// Exception thrown by [Ticker] objects on the [TickerFuture.orCancel] future
...
@@ -464,7 +462,7 @@ class TickerCanceled implements Exception {
...
@@ -464,7 +462,7 @@ class TickerCanceled implements Exception {
///
///
/// This may be null in the case that the [Future] created for
/// This may be null in the case that the [Future] created for
/// [TickerFuture.orCancel] was created after the ticker was canceled.
/// [TickerFuture.orCancel] was created after the ticker was canceled.
final
Ticker
ticker
;
final
Ticker
?
ticker
;
@override
@override
String
toString
()
{
String
toString
()
{
...
...
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