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
34ba6473
Unverified
Commit
34ba6473
authored
Sep 08, 2021
by
Jenn Magder
Committed by
GitHub
Sep 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up null assumptions in devfs to prep for null safety migration (#88934)
parent
4dba7d83
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
53 deletions
+65
-53
asset.dart
packages/flutter_tools/lib/src/asset.dart
+41
-34
devfs.dart
packages/flutter_tools/lib/src/devfs.dart
+24
-19
No files found.
packages/flutter_tools/lib/src/asset.dart
View file @
34ba6473
...
...
@@ -37,8 +37,8 @@ const String kFontManifestJson = 'FontManifest.json';
const
List
<
Map
<
String
,
Object
>>
kMaterialFonts
=
<
Map
<
String
,
Object
>>[
<
String
,
Object
>{
'family'
:
'MaterialIcons'
,
'fonts'
:
<
Map
<
String
,
Object
>>[
<
String
,
Object
>{
'fonts'
:
<
Map
<
String
,
String
>>[
<
String
,
String
>{
'asset'
:
'fonts/MaterialIcons-Regular.otf'
,
},
],
...
...
@@ -161,7 +161,8 @@ class ManifestAssetBundle implements AssetBundle {
@override
bool
needsBuild
({
String
manifestPath
=
defaultManifestPath
})
{
if
(
_lastBuildTimestamp
==
null
)
{
final
DateTime
lastBuildTimestamp
=
_lastBuildTimestamp
;
if
(
lastBuildTimestamp
==
null
)
{
return
true
;
}
...
...
@@ -179,13 +180,13 @@ class ManifestAssetBundle implements AssetBundle {
if
(
dateTime
==
null
)
{
continue
;
}
if
(
dateTime
.
isAfter
(
_
lastBuildTimestamp
))
{
if
(
dateTime
.
isAfter
(
lastBuildTimestamp
))
{
return
true
;
}
}
}
return
stat
.
modified
.
isAfter
(
_
lastBuildTimestamp
);
return
stat
.
modified
.
isAfter
(
lastBuildTimestamp
);
}
@override
...
...
@@ -267,9 +268,7 @@ class ManifestAssetBundle implements AssetBundle {
if
(!
_splitDeferredAssets
||
!
deferredComponentsEnabled
)
{
// Include the assets in the regular set of assets if not using deferred
// components.
for
(
final
String
componentName
in
deferredComponentsAssetVariants
.
keys
)
{
assetVariants
.
addAll
(
deferredComponentsAssetVariants
[
componentName
]);
}
deferredComponentsAssetVariants
.
values
.
forEach
(
assetVariants
.
addAll
);
deferredComponentsAssetVariants
.
clear
();
deferredComponentsEntries
.
clear
();
}
...
...
@@ -457,7 +456,7 @@ class ManifestAssetBundle implements AssetBundle {
return
;
}
final
DevFSStringContent
oldContent
=
entries
[
key
]
as
DevFSStringContent
;
if
(
oldContent
.
string
!=
content
.
string
)
{
if
(
oldContent
?
.
string
!=
content
.
string
)
{
entries
[
key
]
=
content
;
}
}
...
...
@@ -479,8 +478,8 @@ class ManifestAssetBundle implements AssetBundle {
// the uncompressed strings to not incur decompression/decoding while making
// the comparison.
if
(!
entries
.
containsKey
(
_kNoticeZippedFile
)
||
!
(
entries
[
_kNoticeZippedFile
]
as
DevFSStringCompressingBytesContent
)
.
equals
(
combinedLicenses
)
)
{
(
entries
[
_kNoticeZippedFile
]
as
DevFSStringCompressingBytesContent
)
?.
equals
(
combinedLicenses
)
!=
true
)
{
entries
[
_kNoticeZippedFile
]
=
DevFSStringCompressingBytesContent
(
combinedLicenses
,
// A zlib dictionary is a hinting string sequence with the most
...
...
@@ -494,8 +493,16 @@ class ManifestAssetBundle implements AssetBundle {
List
<
_Asset
>
_getMaterialAssets
()
{
final
List
<
_Asset
>
result
=
<
_Asset
>[];
for
(
final
Map
<
String
,
Object
>
family
in
kMaterialFonts
)
{
for
(
final
Map
<
String
,
Object
>
font
in
family
[
'fonts'
]
as
List
<
Map
<
String
,
Object
>>)
{
final
Uri
entryUri
=
_fileSystem
.
path
.
toUri
(
font
[
'asset'
]
as
String
);
final
Object
fonts
=
family
[
'fonts'
];
if
(
fonts
==
null
)
{
continue
;
}
for
(
final
Map
<
String
,
Object
>
font
in
fonts
as
List
<
Map
<
String
,
String
>>)
{
final
String
asset
=
font
[
'asset'
]
as
String
;
if
(
asset
==
null
)
{
continue
;
}
final
Uri
entryUri
=
_fileSystem
.
path
.
toUri
(
asset
);
result
.
add
(
_Asset
(
baseDir:
_fileSystem
.
path
.
join
(
Cache
.
flutterRoot
,
'bin'
,
'cache'
,
'artifacts'
,
'material_fonts'
),
relativeUri:
Uri
(
path:
entryUri
.
pathSegments
.
last
),
...
...
@@ -577,22 +584,21 @@ class ManifestAssetBundle implements AssetBundle {
Map
<
String
,
Map
<
_Asset
,
List
<
_Asset
>>>
deferredComponentsAssetVariants
)
{
final
Map
<
String
,
List
<
String
>>
jsonObject
=
<
String
,
List
<
String
>>{};
final
List
<
_Asset
>
assets
=
assetVariants
.
keys
.
toList
();
final
Map
<
_Asset
,
List
<
String
>>
jsonEntries
=
<
_Asset
,
List
<
String
>>{};
for
(
final
_Asset
main
in
asse
ts
)
{
assetVariants
.
forEach
((
_Asset
main
,
List
<
_Asset
>
varian
ts
)
{
jsonEntries
[
main
]
=
<
String
>[
for
(
final
_Asset
variant
in
assetVariants
[
main
]
)
for
(
final
_Asset
variant
in
variants
)
variant
.
entryUri
.
path
,
];
}
}
);
if
(
deferredComponentsAssetVariants
!=
null
)
{
for
(
final
Map
<
_Asset
,
List
<
_Asset
>>
componentAssets
in
deferredComponentsAssetVariants
.
values
)
{
for
(
final
_Asset
main
in
componentAssets
.
key
s
)
{
componentAssets
.
forEach
((
_Asset
main
,
List
<
_Asset
>
variant
s
)
{
jsonEntries
[
main
]
=
<
String
>[
for
(
final
_Asset
variant
in
componentAssets
[
main
]
)
for
(
final
_Asset
variant
in
variants
)
variant
.
entryUri
.
path
,
];
}
}
);
}
}
final
List
<
_Asset
>
sortedKeys
=
jsonEntries
.
keys
.
toList
()
...
...
@@ -617,7 +623,7 @@ class ManifestAssetBundle implements AssetBundle {
final
Uri
assetUri
=
fontAsset
.
assetUri
;
if
(
assetUri
.
pathSegments
.
first
==
'packages'
&&
!
_fileSystem
.
isFileSync
(
_fileSystem
.
path
.
fromUri
(
packageConfig
[
packageName
]
.
packageUriRoot
.
resolve
(
'../
${assetUri.path}
'
))))
{
packageConfig
[
packageName
]
?.
packageUriRoot
?
.
resolve
(
'../
${assetUri.path}
'
))))
{
packageFontAssets
.
add
(
FontAsset
(
fontAsset
.
assetUri
,
weight:
fontAsset
.
weight
,
...
...
@@ -788,16 +794,17 @@ class ManifestAssetBundle implements AssetBundle {
final
Uri
relativeUri
=
_fileSystem
.
path
.
toUri
(
relativePath
);
final
Uri
entryUri
=
asset
.
symbolicPrefixUri
==
null
?
relativeUri
:
asset
.
symbolicPrefixUri
.
resolveUri
(
relativeUri
);
variants
.
add
(
_Asset
(
baseDir:
asset
.
baseDir
,
entryUri:
entryUri
,
relativeUri:
relativeUri
,
package:
attributedPackage
,
),
);
:
asset
.
symbolicPrefixUri
?.
resolveUri
(
relativeUri
);
if
(
entryUri
!=
null
)
{
variants
.
add
(
_Asset
(
baseDir:
asset
.
baseDir
,
entryUri:
entryUri
,
relativeUri:
relativeUri
,
package:
attributedPackage
,
),
);
}
}
result
[
asset
]
=
variants
;
...
...
@@ -862,9 +869,9 @@ class ManifestAssetBundle implements AssetBundle {
@immutable
class
_Asset
{
const
_Asset
({
this
.
baseDir
,
this
.
relativeUri
,
this
.
entryUri
,
@required
this
.
baseDir
,
@required
this
.
relativeUri
,
@required
this
.
entryUri
,
@required
this
.
package
,
});
...
...
packages/flutter_tools/lib/src/devfs.dart
View file @
34ba6473
...
...
@@ -64,8 +64,9 @@ class DevFSFileContent extends DevFSContent {
FileStat
_fileStat
;
File
_getFile
()
{
if
(
_linkTarget
!=
null
)
{
return
_linkTarget
;
final
File
linkTarget
=
_linkTarget
;
if
(
linkTarget
!=
null
)
{
return
linkTarget
;
}
if
(
file
is
Link
)
{
// The link target.
...
...
@@ -75,9 +76,10 @@ class DevFSFileContent extends DevFSContent {
}
void
_stat
()
{
if
(
_linkTarget
!=
null
)
{
final
File
linkTarget
=
_linkTarget
;
if
(
linkTarget
!=
null
)
{
// Stat the cached symlink target.
final
FileStat
fileStat
=
_
linkTarget
.
statSync
();
final
FileStat
fileStat
=
linkTarget
.
statSync
();
if
(
fileStat
.
type
==
FileSystemEntityType
.
notFound
)
{
_linkTarget
=
null
;
}
else
{
...
...
@@ -87,7 +89,7 @@ class DevFSFileContent extends DevFSContent {
}
final
FileStat
fileStat
=
file
.
statSync
();
_fileStat
=
fileStat
.
type
==
FileSystemEntityType
.
notFound
?
null
:
fileStat
;
if
(
_fileStat
!=
null
&&
_fileStat
.
type
==
FileSystemEntityType
.
link
)
{
if
(
_fileStat
!=
null
&&
_fileStat
?
.
type
==
FileSystemEntityType
.
link
)
{
// Resolve, stat, and maybe cache the symlink target.
final
String
resolved
=
file
.
resolveSymbolicLinksSync
();
final
File
linkTarget
=
file
.
fileSystem
.
file
(
resolved
);
...
...
@@ -96,7 +98,7 @@ class DevFSFileContent extends DevFSContent {
if
(
fileStat
.
type
==
FileSystemEntityType
.
notFound
)
{
_fileStat
=
null
;
_linkTarget
=
null
;
}
else
if
(
devFSConfig
.
cacheSymlinks
)
{
}
else
if
(
devFSConfig
?.
cacheSymlinks
==
true
)
{
_linkTarget
=
linkTarget
;
}
}
...
...
@@ -104,25 +106,27 @@ class DevFSFileContent extends DevFSContent {
@override
bool
get
isModified
{
final
FileStat
_
oldFileStat
=
_fileStat
;
final
FileStat
oldFileStat
=
_fileStat
;
_stat
();
if
(
_oldFileStat
==
null
&&
_fileStat
==
null
)
{
final
FileStat
newFileStat
=
_fileStat
;
if
(
oldFileStat
==
null
&&
newFileStat
==
null
)
{
return
false
;
}
return
_oldFileStat
==
null
||
_fileStat
==
null
||
_fileStat
.
modified
.
isAfter
(
_
oldFileStat
.
modified
);
return
oldFileStat
==
null
||
newFileStat
==
null
||
newFileStat
.
modified
.
isAfter
(
oldFileStat
.
modified
);
}
@override
bool
isModifiedAfter
(
DateTime
time
)
{
final
FileStat
_
oldFileStat
=
_fileStat
;
final
FileStat
oldFileStat
=
_fileStat
;
_stat
();
if
(
_oldFileStat
==
null
&&
_fileStat
==
null
)
{
final
FileStat
newFileStat
=
_fileStat
;
if
(
oldFileStat
==
null
&&
newFileStat
==
null
)
{
return
false
;
}
return
time
==
null
||
_
oldFileStat
==
null
||
_f
ileStat
==
null
||
_f
ileStat
.
modified
.
isAfter
(
time
);
||
oldFileStat
==
null
||
newF
ileStat
==
null
||
newF
ileStat
.
modified
.
isAfter
(
time
);
}
@override
...
...
@@ -135,7 +139,7 @@ class DevFSFileContent extends DevFSContent {
}
@override
Future
<
List
<
int
>>
contentsAsBytes
()
=>
_getFile
().
readAsBytes
();
Future
<
List
<
int
>>
contentsAsBytes
()
async
=>
_getFile
().
readAsBytes
();
@override
Stream
<
List
<
int
>>
contentsAsStream
()
=>
_getFile
().
openRead
();
...
...
@@ -308,8 +312,8 @@ class _DevFSHttpWriter implements DevFSWriter {
static
const
int
kMaxInFlight
=
3
;
int
_inFlight
=
0
;
Map
<
Uri
,
DevFSContent
>
_outstanding
;
Completer
<
void
>
_completer
;
Map
<
Uri
,
DevFSContent
>
_outstanding
=
<
Uri
,
DevFSContent
>{}
;
Completer
<
void
>
_completer
=
Completer
<
void
>()
;
@override
Future
<
void
>
write
(
Map
<
Uri
,
DevFSContent
>
entries
,
Uri
devFSBase
,
[
DevFSWriter
parent
])
async
{
...
...
@@ -553,8 +557,9 @@ class DevFS {
/// If any other changes were made, or there is an error scanning the file,
/// return `null`.
String
_checkIfSingleWidgetReloadApplied
()
{
if
(
_widgetCacheOutputFile
!=
null
&&
_widgetCacheOutputFile
.
existsSync
())
{
final
String
widget
=
_widgetCacheOutputFile
.
readAsStringSync
().
trim
();
final
File
widgetCacheOutputFile
=
_widgetCacheOutputFile
;
if
(
widgetCacheOutputFile
!=
null
&&
widgetCacheOutputFile
.
existsSync
())
{
final
String
widget
=
widgetCacheOutputFile
.
readAsStringSync
().
trim
();
if
(
widget
.
isNotEmpty
)
{
return
widget
;
}
...
...
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