Partial migration to null safety (#63)
Migrated `elinux_cache.dart` to null safety.
This commit is contained in:
+19
-18
@@ -3,8 +3,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_tools/src/base/common.dart';
|
import 'package:flutter_tools/src/base/common.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
import 'package:flutter_tools/src/base/logger.dart';
|
import 'package:flutter_tools/src/base/logger.dart';
|
||||||
@@ -13,22 +11,20 @@ import 'package:flutter_tools/src/base/platform.dart';
|
|||||||
import 'package:flutter_tools/src/cache.dart';
|
import 'package:flutter_tools/src/cache.dart';
|
||||||
import 'package:flutter_tools/src/features.dart';
|
import 'package:flutter_tools/src/features.dart';
|
||||||
import 'package:flutter_tools/src/flutter_cache.dart';
|
import 'package:flutter_tools/src/flutter_cache.dart';
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
import 'package:flutter_tools/src/globals_null_migrated.dart' as globals;
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
|
|
||||||
/// See: [DevelopmentArtifact] in `cache.dart`
|
/// See: [DevelopmentArtifact] in `cache.dart`
|
||||||
class ELinuxDevelopmentArtifact implements DevelopmentArtifact {
|
class ELinuxDevelopmentArtifact implements DevelopmentArtifact {
|
||||||
const ELinuxDevelopmentArtifact._(this.name, this.feature);
|
const ELinuxDevelopmentArtifact._(this.name, {this.feature});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final Feature feature;
|
final Feature? feature;
|
||||||
|
|
||||||
static const DevelopmentArtifact elinux =
|
static const DevelopmentArtifact elinux =
|
||||||
ELinuxDevelopmentArtifact._('elinux', null);
|
ELinuxDevelopmentArtifact._('elinux');
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extends [FlutterCache] to register [ELinuxEngineArtifacts].
|
/// Extends [FlutterCache] to register [ELinuxEngineArtifacts].
|
||||||
@@ -36,10 +32,10 @@ class ELinuxDevelopmentArtifact implements DevelopmentArtifact {
|
|||||||
/// See: [FlutterCache] in `flutter_cache.dart`
|
/// See: [FlutterCache] in `flutter_cache.dart`
|
||||||
class ELinuxFlutterCache extends FlutterCache {
|
class ELinuxFlutterCache extends FlutterCache {
|
||||||
ELinuxFlutterCache({
|
ELinuxFlutterCache({
|
||||||
@required Logger logger,
|
required Logger logger,
|
||||||
@required FileSystem fileSystem,
|
required FileSystem fileSystem,
|
||||||
@required Platform platform,
|
required Platform platform,
|
||||||
@required OperatingSystemUtils osUtils,
|
required OperatingSystemUtils osUtils,
|
||||||
}) : super(
|
}) : super(
|
||||||
logger: logger,
|
logger: logger,
|
||||||
fileSystem: fileSystem,
|
fileSystem: fileSystem,
|
||||||
@@ -52,7 +48,7 @@ class ELinuxFlutterCache extends FlutterCache {
|
|||||||
class ELinuxEngineArtifacts extends EngineCachedArtifact {
|
class ELinuxEngineArtifacts extends EngineCachedArtifact {
|
||||||
ELinuxEngineArtifacts(
|
ELinuxEngineArtifacts(
|
||||||
Cache cache, {
|
Cache cache, {
|
||||||
@required Platform platform,
|
required Platform platform,
|
||||||
}) : _platform = platform,
|
}) : _platform = platform,
|
||||||
super(
|
super(
|
||||||
'elinux-sdk',
|
'elinux-sdk',
|
||||||
@@ -63,7 +59,7 @@ class ELinuxEngineArtifacts extends EngineCachedArtifact {
|
|||||||
final Platform _platform;
|
final Platform _platform;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get version {
|
String? get version {
|
||||||
final File versionFile = globals.fs
|
final File versionFile = globals.fs
|
||||||
.directory(Cache.flutterRoot)
|
.directory(Cache.flutterRoot)
|
||||||
.parent
|
.parent
|
||||||
@@ -76,15 +72,20 @@ class ELinuxEngineArtifacts extends EngineCachedArtifact {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String get shortVersion {
|
String get shortVersion {
|
||||||
if (version != null && version.length >= 10) {
|
if (version == null) {
|
||||||
return version.substring(0, 10);
|
throwToolExit(
|
||||||
|
'Failed to get the short revision of the eLinux engine artifact.');
|
||||||
}
|
}
|
||||||
return version;
|
|
||||||
|
if (version!.length >= 10) {
|
||||||
|
return version!.substring(0, 10);
|
||||||
|
}
|
||||||
|
return version!;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See: [Cache.storageBaseUrl] in `cache.dart`
|
/// See: [Cache.storageBaseUrl] in `cache.dart`
|
||||||
String get engineBaseUrl {
|
String get engineBaseUrl {
|
||||||
final String overrideUrl = _platform.environment['ELINUX_ENGINE_BASE_URL'];
|
final String? overrideUrl = _platform.environment['ELINUX_ENGINE_BASE_URL'];
|
||||||
if (overrideUrl == null) {
|
if (overrideUrl == null) {
|
||||||
return 'https://github.com/sony/flutter-embedded-linux/releases';
|
return 'https://github.com/sony/flutter-embedded-linux/releases';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user