Unverified Commit a83abaa3 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate fingerprint to null safety (#79587)

parent bc4bda02
...@@ -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 '../base/common.dart'; import '../base/common.dart';
import '../build_info.dart'; import '../build_info.dart';
...@@ -27,7 +25,7 @@ void validateBuild(AndroidBuildInfo androidBuildInfo) { ...@@ -27,7 +25,7 @@ void validateBuild(AndroidBuildInfo androidBuildInfo) {
); );
} }
if (buildInfo.buildNumber != null) { if (buildInfo.buildNumber != null) {
final int result = int.tryParse(buildInfo.buildNumber); final int? result = int.tryParse(buildInfo.buildNumber!);
if (result == null) { if (result == null) {
throwToolExit( throwToolExit(
'buildNumber: ${buildInfo.buildNumber} was not a valid integer value.\n' 'buildNumber: ${buildInfo.buildNumber} was not a valid integer value.\n'
......
...@@ -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:crypto/crypto.dart' show md5; import 'package:crypto/crypto.dart' show md5;
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
...@@ -19,10 +17,10 @@ import 'utils.dart'; ...@@ -19,10 +17,10 @@ import 'utils.dart';
/// such as checking if Cocoapods should be run. /// such as checking if Cocoapods should be run.
class Fingerprinter { class Fingerprinter {
Fingerprinter({ Fingerprinter({
@required this.fingerprintPath, required this.fingerprintPath,
@required Iterable<String> paths, required Iterable<String> paths,
@required FileSystem fileSystem, required FileSystem fileSystem,
@required Logger logger, required Logger logger,
}) : _paths = paths.toList(), }) : _paths = paths.toList(),
assert(fingerprintPath != null), assert(fingerprintPath != null),
assert(paths != null && paths.every((String path) => path != null)), assert(paths != null && paths.every((String path) => path != null)),
...@@ -81,8 +79,8 @@ class Fingerprinter { ...@@ -81,8 +79,8 @@ class Fingerprinter {
@immutable @immutable
class Fingerprint { class Fingerprint {
const Fingerprint._({ const Fingerprint._({
Map<String, String> checksums, Map<String, String>? checksums,
}) : _checksums = checksums; }) : _checksums = checksums ?? const <String, String>{};
factory Fingerprint.fromBuildInputs(Iterable<String> inputPaths, FileSystem fileSystem) { factory Fingerprint.fromBuildInputs(Iterable<String> inputPaths, FileSystem fileSystem) {
final Iterable<File> files = inputPaths.map<File>(fileSystem.file); final Iterable<File> files = inputPaths.map<File>(fileSystem.file);
...@@ -103,9 +101,12 @@ class Fingerprint { ...@@ -103,9 +101,12 @@ class Fingerprint {
/// Throws [Exception], if there is a version mismatch between the /// Throws [Exception], if there is a version mismatch between the
/// serializing framework and this framework. /// serializing framework and this framework.
factory Fingerprint.fromJson(String jsonData) { factory Fingerprint.fromJson(String jsonData) {
final Map<String, dynamic> content = castStringKeyedMap(json.decode(jsonData)); final Map<String, dynamic>? content = castStringKeyedMap(json.decode(jsonData));
final Map<String, String>? files = content == null
? null
: castStringKeyedMap(content['files'])?.cast<String, String>();
return Fingerprint._( return Fingerprint._(
checksums: castStringKeyedMap(content['files'])?.cast<String,String>() ?? <String, String>{}, checksums: files ?? <String, String>{},
); );
} }
......
...@@ -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:test_core/src/executable.dart' as test; // ignore: implementation_imports import 'package:test_core/src/executable.dart' as test; // ignore: implementation_imports
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment