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
5398c34c
Unverified
Commit
5398c34c
authored
Mar 24, 2021
by
Jenn Magder
Committed by
GitHub
Mar 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate flutter_project_metadata to null safety (#78944)
parent
63d6ec56
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
36 deletions
+26
-36
package_map.dart
packages/flutter_tools/lib/src/dart/package_map.dart
+3
-6
flutter_project_metadata.dart
packages/flutter_tools/lib/src/flutter_project_metadata.dart
+11
-13
license_collector.dart
packages/flutter_tools/lib/src/license_collector.dart
+8
-11
memory_fs.dart
packages/flutter_tools/lib/src/web/memory_fs.dart
+4
-6
No files found.
packages/flutter_tools/lib/src/dart/package_map.dart
View file @
5398c34c
...
...
@@ -2,11 +2,8 @@
// 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:typed_data'
;
import
'package:meta/meta.dart'
;
import
'package:package_config/package_config.dart'
;
import
'../base/common.dart'
;
...
...
@@ -19,14 +16,14 @@ import '../base/logger.dart';
/// If [throwOnError] is false, in the event of an error an empty package
/// config is returned.
Future
<
PackageConfig
>
loadPackageConfigWithLogging
(
File
file
,
{
@
required
Logger
logger
,
required
Logger
logger
,
bool
throwOnError
=
true
,
})
async
{
final
FileSystem
fileSystem
=
file
.
fileSystem
;
bool
didError
=
false
;
final
PackageConfig
result
=
await
loadPackageConfigUri
(
file
.
absolute
.
uri
,
loader:
(
Uri
uri
)
{
loader:
(
Uri
uri
)
async
{
final
File
configFile
=
fileSystem
.
file
(
uri
);
if
(!
configFile
.
existsSync
())
{
return
null
;
...
...
@@ -50,7 +47,7 @@ Future<PackageConfig> loadPackageConfigWithLogging(File file, {
}
);
if
(
didError
)
{
throwToolExit
(
null
);
throwToolExit
(
''
);
}
return
result
;
}
packages/flutter_tools/lib/src/flutter_project_metadata.dart
View file @
5398c34c
...
...
@@ -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
'package:yaml/yaml.dart'
;
import
'base/file_system.dart'
;
...
...
@@ -29,8 +27,8 @@ String flutterProjectTypeToString(FlutterProjectType type) {
return
getEnumName
(
type
);
}
FlutterProjectType
stringToProjectType
(
String
value
)
{
FlutterProjectType
result
;
FlutterProjectType
?
stringToProjectType
(
String
value
)
{
FlutterProjectType
?
result
;
for
(
final
FlutterProjectType
type
in
FlutterProjectType
.
values
)
{
if
(
value
==
flutterProjectTypeToString
(
type
))
{
result
=
type
;
...
...
@@ -51,10 +49,10 @@ class FlutterProjectMetadata {
final
File
_metadataFile
;
final
Logger
_logger
;
String
get
versionChannel
=>
_versionValue
(
'channel'
);
String
get
versionRevision
=>
_versionValue
(
'revision'
);
String
?
get
versionChannel
=>
_versionValue
(
'channel'
);
String
?
get
versionRevision
=>
_versionValue
(
'revision'
);
FlutterProjectType
get
projectType
{
FlutterProjectType
?
get
projectType
{
final
dynamic
projectTypeYaml
=
_metadataValue
(
'project_type'
);
if
(
projectTypeYaml
is
String
)
{
return
stringToProjectType
(
projectTypeYaml
);
...
...
@@ -64,8 +62,8 @@ class FlutterProjectMetadata {
}
}
YamlMap
_versionYaml
;
String
_versionValue
(
String
key
)
{
YamlMap
?
_versionYaml
;
String
?
_versionValue
(
String
key
)
{
if
(
_versionYaml
==
null
)
{
final
dynamic
versionYaml
=
_metadataValue
(
'version'
);
if
(
versionYaml
is
YamlMap
)
{
...
...
@@ -75,13 +73,13 @@ class FlutterProjectMetadata {
return
null
;
}
}
if
(
_versionYaml
!=
null
&&
_versionYaml
.
containsKey
(
key
)
&&
_versionYaml
[
key
]
is
String
)
{
return
_versionYaml
[
key
]
as
String
;
if
(
_versionYaml
!=
null
&&
_versionYaml
!.
containsKey
(
key
)
&&
_versionYaml
!
[
key
]
is
String
)
{
return
_versionYaml
!
[
key
]
as
String
;
}
return
null
;
}
YamlMap
_metadataYaml
;
YamlMap
?
_metadataYaml
;
dynamic
_metadataValue
(
String
key
)
{
if
(
_metadataYaml
==
null
)
{
if
(!
_metadataFile
.
existsSync
())
{
...
...
@@ -101,6 +99,6 @@ class FlutterProjectMetadata {
}
}
return
_metadataYaml
[
key
];
return
_metadataYaml
!
[
key
];
}
}
packages/flutter_tools/lib/src/license_collector.dart
View file @
5398c34c
...
...
@@ -2,9 +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
'package:meta/meta.dart'
;
import
'package:package_config/package_config.dart'
;
import
'base/file_system.dart'
;
...
...
@@ -28,7 +25,7 @@ import 'base/file_system.dart';
/// sources, and might need to include a license for each one.
class
LicenseCollector
{
LicenseCollector
({
@
required
FileSystem
fileSystem
required
FileSystem
fileSystem
})
:
_fileSystem
=
fileSystem
;
final
FileSystem
_fileSystem
;
...
...
@@ -67,8 +64,8 @@ class LicenseCollector {
.
readAsStringSync
()
.
split
(
licenseSeparator
);
for
(
final
String
rawLicense
in
rawLicenses
)
{
List
<
String
>
packageNames
;
String
licenseText
;
List
<
String
>
packageNames
=
<
String
>[]
;
String
?
licenseText
;
if
(
rawLicenses
.
length
>
1
)
{
final
int
split
=
rawLicense
.
indexOf
(
'
\n\n
'
);
if
(
split
>=
0
)
{
...
...
@@ -87,7 +84,7 @@ class LicenseCollector {
final
List
<
String
>
combinedLicensesList
=
packageLicenses
.
keys
.
map
<
String
>((
String
license
)
{
final
List
<
String
>
packageNames
=
packageLicenses
[
license
].
toList
()
final
List
<
String
>
packageNames
=
packageLicenses
[
license
]
!
.
toList
()
..
sort
();
return
packageNames
.
join
(
'
\n
'
)
+
'
\n\n
'
+
license
;
}).
toList
();
...
...
@@ -97,7 +94,7 @@ class LicenseCollector {
final
List
<
String
>
additionalLicenseText
=
<
String
>[];
final
List
<
String
>
errorMessages
=
<
String
>[];
for
(
final
String
package
in
additionalLicenses
.
keys
)
{
for
(
final
File
license
in
additionalLicenses
[
package
])
{
for
(
final
File
license
in
additionalLicenses
[
package
]
!
)
{
if
(!
license
.
existsSync
())
{
errorMessages
.
add
(
'package
$package
specified an additional license at
${license.path}
, but this file '
...
...
@@ -146,9 +143,9 @@ class LicenseCollector {
/// The result of processing licenses with a [LicenseCollector].
class
LicenseResult
{
const
LicenseResult
({
@
required
this
.
combinedLicenses
,
@
required
this
.
dependencies
,
@
required
this
.
errorMessages
,
required
this
.
combinedLicenses
,
required
this
.
dependencies
,
required
this
.
errorMessages
,
});
/// The raw text of the consumed licenses.
...
...
packages/flutter_tools/lib/src/web/memory_fs.dart
View file @
5398c34c
...
...
@@ -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:typed_data'
;
import
'../base/file_system.dart'
;
...
...
@@ -20,8 +18,8 @@ class WebMemoryFS {
final
Map
<
String
,
Uint8List
>
files
=
<
String
,
Uint8List
>{};
final
Map
<
String
,
Uint8List
>
sourcemaps
=
<
String
,
Uint8List
>{};
String
get
mergedMetadata
=>
_mergedMetadata
;
String
_mergedMetadata
;
String
?
get
mergedMetadata
=>
_mergedMetadata
;
String
?
_mergedMetadata
;
/// Update the filesystem with the provided source and manifest files.
///
...
...
@@ -37,13 +35,13 @@ class WebMemoryFS {
final
Uint8List
sourcemapBytes
=
sourcemapFile
.
readAsBytesSync
();
final
Uint8List
metadataBytes
=
metadataFile
.
readAsBytesSync
();
final
Map
<
String
,
dynamic
>
manifest
=
castStringKeyedMap
(
json
.
decode
(
manifestFile
.
readAsStringSync
()));
castStringKeyedMap
(
json
.
decode
(
manifestFile
.
readAsStringSync
()))
!
;
for
(
final
String
filePath
in
manifest
.
keys
)
{
if
(
filePath
==
null
)
{
continue
;
}
final
Map
<
String
,
dynamic
>
offsets
=
castStringKeyedMap
(
manifest
[
filePath
]);
castStringKeyedMap
(
manifest
[
filePath
])
!
;
final
List
<
int
>
codeOffsets
=
(
offsets
[
'code'
]
as
List
<
dynamic
>).
cast
<
int
>();
final
List
<
int
>
sourcemapOffsets
=
...
...
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