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
d27666e0
Unverified
Commit
d27666e0
authored
Mar 18, 2021
by
Jonah Williams
Committed by
GitHub
Mar 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] migrate context to null safety (#78359)
parent
cdfe3955
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
19 deletions
+17
-19
context.dart
packages/flutter_tools/lib/src/base/context.dart
+17
-19
No files found.
packages/flutter_tools/lib/src/base/context.dart
View file @
d27666e0
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:collection'
;
...
...
@@ -39,7 +37,7 @@ const Object contextKey = _Key.key;
/// context will not have any values associated with it.
///
/// This is guaranteed to never return `null`.
AppContext
get
context
=>
Zone
.
current
[
contextKey
]
as
AppContext
??
AppContext
.
_root
;
AppContext
get
context
=>
Zone
.
current
[
contextKey
]
as
AppContext
?
??
AppContext
.
_root
;
/// A lookup table (mapping types to values) and an implied scope, in which
/// code is run.
...
...
@@ -58,13 +56,13 @@ class AppContext {
this
.
_fallbacks
=
const
<
Type
,
Generator
>{},
]);
final
String
name
;
final
AppContext
_parent
;
final
String
?
name
;
final
AppContext
?
_parent
;
final
Map
<
Type
,
Generator
>
_overrides
;
final
Map
<
Type
,
Generator
>
_fallbacks
;
final
Map
<
Type
,
dynamic
>
_values
=
<
Type
,
dynamic
>{};
List
<
Type
>
_reentrantChecks
;
List
<
Type
>
?
_reentrantChecks
;
/// Bootstrap context.
static
final
AppContext
_root
=
AppContext
.
_
(
null
,
'ROOT'
);
...
...
@@ -94,19 +92,19 @@ class AppContext {
return
_values
.
putIfAbsent
(
type
,
()
{
_reentrantChecks
??=
<
Type
>[];
final
int
index
=
_reentrantChecks
.
indexOf
(
type
);
final
int
index
=
_reentrantChecks
!
.
indexOf
(
type
);
if
(
index
>=
0
)
{
// We're already in the process of trying to generate this type.
throw
ContextDependencyCycleException
.
_
(
UnmodifiableListView
<
Type
>(
_reentrantChecks
.
sublist
(
index
)));
UnmodifiableListView
<
Type
>(
_reentrantChecks
!
.
sublist
(
index
)));
}
_reentrantChecks
.
add
(
type
);
_reentrantChecks
!
.
add
(
type
);
try
{
return
_boxNull
(
generators
[
type
]());
return
_boxNull
(
generators
[
type
]
!
());
}
finally
{
_reentrantChecks
.
removeLast
();
if
(
_reentrantChecks
.
isEmpty
)
{
_reentrantChecks
!
.
removeLast
();
if
(
_reentrantChecks
!
.
isEmpty
)
{
_reentrantChecks
=
null
;
}
}
...
...
@@ -118,7 +116,7 @@ class AppContext {
T
get
<
T
>()
{
dynamic
value
=
_generateIfNecessary
(
T
,
_overrides
);
if
(
value
==
null
&&
_parent
!=
null
)
{
value
=
_parent
.
get
<
T
>();
value
=
_parent
!
.
get
<
T
>();
}
return
_unboxNull
(
value
??
_generateIfNecessary
(
T
,
_fallbacks
))
as
T
;
}
...
...
@@ -136,11 +134,11 @@ class AppContext {
/// name. This is useful for debugging purposes and is analogous to naming a
/// thread in Java.
Future
<
V
>
run
<
V
>({
@
required
FutureOr
<
V
>
Function
()
body
,
String
name
,
Map
<
Type
,
Generator
>
overrides
,
Map
<
Type
,
Generator
>
fallbacks
,
ZoneSpecification
zoneSpecification
,
required
FutureOr
<
V
>
Function
()
body
,
String
?
name
,
Map
<
Type
,
Generator
>
?
overrides
,
Map
<
Type
,
Generator
>
?
fallbacks
,
ZoneSpecification
?
zoneSpecification
,
})
async
{
final
AppContext
child
=
AppContext
.
_
(
this
,
...
...
@@ -159,7 +157,7 @@ class AppContext {
String
toString
()
{
final
StringBuffer
buf
=
StringBuffer
();
String
indent
=
''
;
AppContext
ctx
=
this
;
AppContext
?
ctx
=
this
;
while
(
ctx
!=
null
)
{
buf
.
write
(
'AppContext'
);
if
(
ctx
.
name
!=
null
)
{
...
...
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