diff --git a/bin/flutter_elinux.dart b/bin/flutter_elinux.dart index 72ba4ff..22723a0 100644 --- a/bin/flutter_elinux.dart +++ b/bin/flutter_elinux.dart @@ -1,10 +1,8 @@ -// Copyright 2021 Sony Group Corporation. All rights reserved. +// Copyright 2023 Sony Group Corporation. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // 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:flutter_elinux/executable.dart' as executable; void main(List args) { diff --git a/bin/internal/engine.version b/bin/internal/engine.version index f2e648a..f3e2625 100644 --- a/bin/internal/engine.version +++ b/bin/internal/engine.version @@ -1 +1 @@ -1a65d409c7a1438a34d21b60bf30a6fd5db59314 +d44b5a94c976fbb65815374f61ab5392a220b084 diff --git a/bin/internal/flutter.version b/bin/internal/flutter.version index ca2c9bc..146c21c 100644 --- a/bin/internal/flutter.version +++ b/bin/internal/flutter.version @@ -1 +1 @@ -4d9e56e694b656610ab87fcf2efbcd226e0ed8cf +84a1e904f44f9b0e9c4510138010edcc653163f8 diff --git a/lib/commands/analyze.dart b/lib/commands/analyze.dart index 19047e7..0d0a269 100644 --- a/lib/commands/analyze.dart +++ b/lib/commands/analyze.dart @@ -1,10 +1,8 @@ -// Copyright 2022 Sony Group Corporation. All rights reserved. +// Copyright 2023 Sony Group Corporation. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // 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:flutter_tools/src/commands/analyze.dart'; import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/project_validator.dart'; @@ -12,17 +10,23 @@ import 'package:flutter_tools/src/project_validator.dart'; import '../elinux_plugins.dart'; class ELinuxAnalyzeCommand extends AnalyzeCommand with ELinuxExtension { - ELinuxAnalyzeCommand({bool verboseHelp = false}) + ELinuxAnalyzeCommand({super.verboseHelp}) : super( - verboseHelp: verboseHelp, fileSystem: globals.fs, platform: globals.platform, processManager: globals.processManager, logger: globals.logger, terminal: globals.terminal, - artifacts: globals.artifacts, + artifacts: globals.artifacts!, + // new ProjectValidators should be added here for the --suggestions to run allProjectValidators: [ - GeneralInfoProjectValidator() + GeneralInfoProjectValidator(), + VariableDumpMachineProjectValidator( + logger: globals.logger, + fileSystem: globals.fs, + platform: globals.platform, + ), ], + suppressAnalytics: globals.flutterUsage.suppressAnalytics, ); } diff --git a/lib/commands/build.dart b/lib/commands/build.dart index b949ecf..279685f 100644 --- a/lib/commands/build.dart +++ b/lib/commands/build.dart @@ -3,8 +3,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:flutter_tools/src/android/build_validation.dart' as android; import 'package:flutter_tools/src/base/analyze_size.dart'; import 'package:flutter_tools/src/base/common.dart'; @@ -57,7 +55,6 @@ class BuildPackageCommand extends BuildSubCommand ); argParser.addOption( 'target-compiler-triple', - defaultsTo: null, help: 'Target compiler triple for which the app is compiled. ' 'e.g. aarch64-linux-gnu', ); @@ -70,12 +67,10 @@ class BuildPackageCommand extends BuildSubCommand ); argParser.addOption( 'target-toolchain', - defaultsTo: null, help: 'The toolchain path for Clang.', ); argParser.addOption( 'system-include-directories', - defaultsTo: null, help: 'The additional system include paths to cross-compile for target platform. ' 'This option is valid only ' @@ -83,7 +78,6 @@ class BuildPackageCommand extends BuildSubCommand ); argParser.addOption( 'target-compiler-flags', - defaultsTo: null, help: 'The extra compile flags to be applied to C and C++ compiler', ); } @@ -118,7 +112,7 @@ class BuildPackageCommand extends BuildSubCommand @override Future runCommand() async { // Not supported cross-building for x64 on arm64. - final String targetArch = stringArg('target-arch'); + final String? targetArch = stringArg('target-arch'); final String hostArch = _getCurrentHostPlatformArchName(); if (hostArch != targetArch && hostArch == 'arm64') { globals.logger @@ -129,10 +123,10 @@ class BuildPackageCommand extends BuildSubCommand final BuildInfo buildInfo = await getBuildInfo(); final ELinuxBuildInfo eLinuxBuildInfo = ELinuxBuildInfo( buildInfo, - targetArch: targetArch, - targetBackendType: stringArg('target-backend-type'), + targetArch: targetArch!, + targetBackendType: stringArg('target-backend-type')!, targetCompilerTriple: stringArg('target-compiler-triple'), - targetSysroot: stringArg('target-sysroot'), + targetSysroot: stringArg('target-sysroot')!, targetCompilerFlags: stringArg('target-compiler-flags'), targetToolchain: stringArg('target-toolchain'), systemIncludeDirectories: stringArg('system-include-directories'), diff --git a/lib/commands/clean.dart b/lib/commands/clean.dart index c98de71..ad90b45 100644 --- a/lib/commands/clean.dart +++ b/lib/commands/clean.dart @@ -1,10 +1,8 @@ -// Copyright 2021 Sony Group Corporation. All rights reserved. +// Copyright 2023 Sony Group Corporation. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // 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:file/file.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/commands/clean.dart'; @@ -16,7 +14,7 @@ import 'package:path/path.dart'; import '../elinux_cmake_project.dart'; class ELinuxCleanCommand extends CleanCommand { - ELinuxCleanCommand({bool verbose = false}) : super(verbose: verbose); + ELinuxCleanCommand({super.verbose}); /// See: [CleanCommand.runCommand] in `clean.dart` @override @@ -48,7 +46,7 @@ class ELinuxCleanCommand extends CleanCommand { } on FileSystemException catch (error) { globals.printError('Failed to remove $path: $error'); } finally { - status?.stop(); + status.stop(); } } } diff --git a/lib/commands/create.dart b/lib/commands/create.dart index 3e538ed..b18d680 100644 --- a/lib/commands/create.dart +++ b/lib/commands/create.dart @@ -1,11 +1,9 @@ -// Copyright 2022 Sony Group Corporation. All rights reserved. +// Copyright 2023 Sony Group Corporation. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2014 The Flutter Authors. All rights reserved. // 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:io'; import 'package:flutter_tools/src/base/common.dart'; @@ -30,11 +28,10 @@ const List _kAvailablePlatforms = [ ]; class ELinuxCreateCommand extends CreateCommand { - ELinuxCreateCommand({bool verboseHelp = false}) - : super(verboseHelp: verboseHelp); + ELinuxCreateCommand({super.verboseHelp}); @override - void addPlatformsOptions({String customHelp}) { + void addPlatformsOptions({String? customHelp}) { argParser.addMultiOption( 'platforms', help: customHelp, @@ -47,7 +44,7 @@ class ELinuxCreateCommand extends CreateCommand { Future renderTemplate( String templateName, Directory directory, - Map context, { + Map context, { bool overwrite = false, bool printStatusWhenWriting = true, }) async { @@ -67,7 +64,7 @@ class ELinuxCreateCommand extends CreateCommand { Future renderMerged( List names, Directory directory, - Map context, { + Map context, { bool overwrite = false, bool printStatusWhenWriting = true, }) async { @@ -79,14 +76,14 @@ class ELinuxCreateCommand extends CreateCommand { fileSystem: globals.fs, logger: globals.logger, templateRenderer: globals.templateRenderer, - templateManifest: null, + templateManifest: {}, ); return template.render(directory, context, overwriteExisting: overwrite); } /// See: [CreateCommand._getProjectType] in `create.dart` bool get _shouldGeneratePlugin { - if (argResults['template'] != null) { + if (argResults!['template'] != null) { return stringArg('template') == 'plugin'; } else if (projectDir.existsSync() && projectDir.listSync().isNotEmpty) { return determineTemplateType() == FlutterProjectType.plugin; @@ -114,7 +111,7 @@ class ELinuxCreateCommand extends CreateCommand { // The dart project_name is in snake_case, this variable is the Title Case of the Project Name. final String titleCaseProjectName = snakeCaseToTitleCase(projectName); - final Map templateContext = createTemplateContext( + final Map templateContext = createTemplateContext( organization: '', projectName: projectName, flutterRoot: '', @@ -140,12 +137,12 @@ class ELinuxCreateCommand extends CreateCommand { /// - [Template.render] in `template.dart` @override Future runCommand() async { - if (argResults.rest.isEmpty) { + if (argResults!.rest.isEmpty) { return super.runCommand(); } final List platforms = stringsArg('platforms'); bool shouldRenderELinuxTemplate = platforms.contains('elinux'); - if (_shouldGeneratePlugin && !argResults.wasParsed('platforms')) { + if (_shouldGeneratePlugin && !argResults!.wasParsed('platforms')) { shouldRenderELinuxTemplate = false; } if (!shouldRenderELinuxTemplate) { diff --git a/lib/commands/drive.dart b/lib/commands/drive.dart index 5de8158..32814c6 100644 --- a/lib/commands/drive.dart +++ b/lib/commands/drive.dart @@ -3,8 +3,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:flutter_tools/src/commands/drive.dart'; import 'package:flutter_tools/src/globals.dart' as globals; @@ -13,9 +11,8 @@ import '../elinux_plugins.dart'; class ELinuxDriveCommand extends DriveCommand with ELinuxExtension, ELinuxRequiredArtifacts { - ELinuxDriveCommand({bool verboseHelp = false}) + ELinuxDriveCommand({super.verboseHelp}) : super( - verboseHelp: verboseHelp, fileSystem: globals.fs, logger: globals.logger, platform: globals.platform, diff --git a/lib/commands/packages.dart b/lib/commands/packages.dart index 27952f7..61c1ab9 100644 --- a/lib/commands/packages.dart +++ b/lib/commands/packages.dart @@ -1,13 +1,12 @@ -// Copyright 2021 Sony Group Corporation. All rights reserved. +// Copyright 2023 Sony Group Corporation. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2014 The Flutter Authors. All rights reserved. // 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:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/commands/packages.dart'; +import 'package:flutter_tools/src/dart/pub.dart'; import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart'; @@ -21,13 +20,18 @@ import '../elinux_plugins.dart'; /// Source: [PackagesCommand] in `packages.dart` class ELinuxPackagesCommand extends FlutterCommand { ELinuxPackagesCommand() { - addSubcommand(ELinuxPackagesGetCommand('get', false)); - addSubcommand(ELinuxPackagesInteractiveGetCommand('upgrade', - "Upgrade the current package's dependencies to latest versions.")); - addSubcommand(ELinuxPackagesInteractiveGetCommand( - 'add', 'Add a dependency to pubspec.yaml.')); - addSubcommand(ELinuxPackagesInteractiveGetCommand( - 'remove', 'Removes a dependency from the current package.')); + addSubcommand(ELinuxPackagesGetCommand( + 'get', "Get the current package's dependencies.", PubContext.pubGet)); + addSubcommand(ELinuxPackagesGetCommand( + 'upgrade', + "Upgrade the current package's dependencies to latest versions.", + PubContext.pubUpgrade)); + addSubcommand(ELinuxPackagesGetCommand( + 'add', 'Add a dependency to pubspec.yaml.', PubContext.pubAdd)); + addSubcommand(ELinuxPackagesGetCommand( + 'remove', + 'Removes a dependency from the current package.', + PubContext.pubRemove)); addSubcommand(PackagesTestCommand()); addSubcommand(PackagesForwardCommand( 'publish', 'Publish the current package to pub.dartlang.org', @@ -65,18 +69,13 @@ class ELinuxPackagesCommand extends FlutterCommand { final String description = 'Commands for managing Flutter packages.'; @override - Future runCommand() async => null; + Future runCommand() async => + FlutterCommandResult.fail(); } class ELinuxPackagesGetCommand extends PackagesGetCommand with _PostRunPluginInjection { - ELinuxPackagesGetCommand(String name, bool upgrade) : super(name, upgrade); -} - -class ELinuxPackagesInteractiveGetCommand extends PackagesInteractiveGetCommand - with _PostRunPluginInjection { - ELinuxPackagesInteractiveGetCommand(String commandName, String description) - : super(commandName, description); + ELinuxPackagesGetCommand(super.commandName, super.description, super.context); } mixin _PostRunPluginInjection on FlutterCommand { @@ -86,9 +85,9 @@ mixin _PostRunPluginInjection on FlutterCommand { final FlutterCommandResult result = await super.runCommand(); if (result == FlutterCommandResult.success()) { - final String workingDirectory = - argResults.rest.isNotEmpty ? argResults.rest[0] : null; - final String target = findProjectRoot(globals.fs, workingDirectory); + final String? workingDirectory = + argResults!.rest.isNotEmpty ? argResults!.rest[0] : null; + final String? target = findProjectRoot(globals.fs, workingDirectory); if (target == null) { return result; } diff --git a/lib/commands/precache.dart b/lib/commands/precache.dart index 35223a8..29c8679 100644 --- a/lib/commands/precache.dart +++ b/lib/commands/precache.dart @@ -1,41 +1,26 @@ -// Copyright 2021 Sony Group Corporation. All rights reserved. +// Copyright 2023 Sony Group Corporation. All rights reserved. // Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. // 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:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/precache.dart'; -import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart'; -import 'package:meta/meta.dart'; - import '../elinux_cache.dart'; class ELinuxPrecacheCommand extends PrecacheCommand { ELinuxPrecacheCommand({ - bool verboseHelp = false, - @required Cache cache, - @required Platform platform, - @required Logger logger, - @required FeatureFlags featureFlags, + super.verboseHelp, + required super.cache, + required super.platform, + required super.logger, + required super.featureFlags, }) : _cache = cache, - _platform = platform, - super( - verboseHelp: verboseHelp, - cache: cache, - platform: platform, - logger: logger, - featureFlags: featureFlags, - ) { + _platform = platform { argParser.addFlag( 'elinux', - negatable: true, - defaultsTo: false, help: 'Precache artifacts for Embedded Linux development.', ); } @@ -46,7 +31,7 @@ class ELinuxPrecacheCommand extends PrecacheCommand { bool get _includeOtherPlatforms => boolArg('android') || DevelopmentArtifact.values.any((DevelopmentArtifact artifact) => - boolArg(artifact.name) && argResults.wasParsed(artifact.name)); + boolArg(artifact.name) && argResults!.wasParsed(artifact.name)); @override Future runCommand() async { @@ -73,7 +58,7 @@ class ELinuxPrecacheCommand extends PrecacheCommand { if (includeAllPlatforms || includeDefaults || _includeOtherPlatforms) { // If the '--force' option is used, the super.runCommand() will delete // the elinux's stamp file. It should be restored. - final String elinuxStamp = _cache.getStampFor(elinuxStampName); + final String? elinuxStamp = _cache.getStampFor(elinuxStampName); final FlutterCommandResult result = await super.runCommand(); if (elinuxStamp != null) { _cache.setStampFor(elinuxStampName, elinuxStamp); diff --git a/lib/commands/run.dart b/lib/commands/run.dart index 3605fea..f98f8d3 100644 --- a/lib/commands/run.dart +++ b/lib/commands/run.dart @@ -1,10 +1,8 @@ -// Copyright 2021 Sony Group Corporation. All rights reserved. +// Copyright 2023 Sony Group Corporation. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // 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:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/cache.dart'; @@ -15,8 +13,7 @@ import '../elinux_plugins.dart'; class ELinuxRunCommand extends RunCommand with ELinuxExtension, ELinuxRequiredArtifacts { - ELinuxRunCommand({bool verboseHelp = false}) - : super(verboseHelp: verboseHelp); + ELinuxRunCommand({super.verboseHelp}); @override Future> get requiredArtifacts async => diff --git a/lib/commands/test.dart b/lib/commands/test.dart index 58cf60d..2baccac 100644 --- a/lib/commands/test.dart +++ b/lib/commands/test.dart @@ -1,15 +1,12 @@ -// Copyright 2021 Sony Group Corporation. All rights reserved. +// Copyright 2023 Sony Group Corporation. All rights reserved. // Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. // 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:flutter_tools/src/commands/test.dart'; import '../elinux_plugins.dart'; class ELinuxTestCommand extends TestCommand with ELinuxExtension { - ELinuxTestCommand({bool verboseHelp = false}) - : super(verboseHelp: verboseHelp); + ELinuxTestCommand({super.verboseHelp}); } diff --git a/lib/commands/upgrade.dart b/lib/commands/upgrade.dart index d98358f..73231bc 100644 --- a/lib/commands/upgrade.dart +++ b/lib/commands/upgrade.dart @@ -3,8 +3,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:convert'; import 'dart:core'; @@ -24,8 +22,8 @@ import 'package:meta/meta.dart'; /// Source: [UpgradeCommand] in `upgrade.dart` class ELinuxUpgradeCommand extends UpgradeCommand { ELinuxUpgradeCommand({ - @required bool verboseHelp, - }) : super(verboseHelp: verboseHelp); + required super.verboseHelp, + }); @override Future runCommand() { @@ -50,25 +48,25 @@ class ELinuxGitTagVersion { ); /// The git hash (or an abbreviation thereof) for this commit. - final String hash; + final String? hash; /// The git short hash (or an abbreviation thereof) for this commit. final String hashShort; /// The git tag that is this version's closest ancestor. - final String gitTag; + final String? gitTag; } /// Source: [UpgradeCommandRunner] in `upgrade.dart` @visibleForTesting class ELinuxUpgradeCommandRunner { - String workingDirectory; + String? workingDirectory; Future runCommand({ - @required bool force, - @required bool continueFlow, - @required bool testFlow, - @required bool verifyOnly, + required bool force, + required bool continueFlow, + required bool testFlow, + required bool verifyOnly, }) async { if (!continueFlow) { await runCommandFirstHalf( @@ -83,9 +81,9 @@ class ELinuxUpgradeCommandRunner { } Future runCommandFirstHalf({ - @required bool force, - @required bool testFlow, - @required bool verifyOnly, + required bool force, + required bool testFlow, + required bool verifyOnly, }) async { ELinuxGitTagVersion upstreamVersion = await fetchTaggedLatestVersion(); final ELinuxGitTagVersion currentVersion = await fetchCurrentVersion(); @@ -98,7 +96,7 @@ class ELinuxUpgradeCommandRunner { if (currentVersion.hash == upstreamVersion.hash) { globals.printStatus('flutter-elinux is already up to date'); - globals.printStatus(upstreamVersion.gitTag); + globals.printStatus(upstreamVersion.gitTag!); return; } @@ -206,8 +204,8 @@ class ELinuxUpgradeCommandRunner { } Future fetchCurrentVersion() async { - String tag; - String latestRevision; + String? tag; + String? latestRevision; try { RunResult result = await globals.processUtils.run( ['git', 'rev-parse', '--verify', 'HEAD'], @@ -243,14 +241,14 @@ class ELinuxUpgradeCommandRunner { } } return ELinuxGitTagVersion( - latestRevision, latestRevision.substring(0, 10), tag); + latestRevision, latestRevision!.substring(0, 10), tag); } /// Source: [attemptReset] in `upgrade.dart` (exact copy) - Future attemptReset(String newRevision) async { + Future attemptReset(String? newRevision) async { try { await globals.processUtils.run( - ['git', 'reset', '--hard', newRevision], + ['git', 'reset', '--hard', newRevision!], throwOnError: true, workingDirectory: workingDirectory, ); @@ -280,12 +278,12 @@ class ELinuxUpgradeCommandRunner { /// Source: [runCommandSecondHalf] in `upgrade.dart` Future runCommandSecondHalf() async { // Make sure the welcome message re-display is delayed until the end. - globals.persistentToolState.setShouldRedisplayWelcomeMessage(false); + globals.persistentToolState?.setShouldRedisplayWelcomeMessage(false); await precacheArtifacts(); await updatePackages(); await runDoctor(); // Force the welcome message to re-display following the upgrade. - globals.persistentToolState.setShouldRedisplayWelcomeMessage(true); + globals.persistentToolState?.setShouldRedisplayWelcomeMessage(true); } /// Source: [precacheArtifacts] in `upgrade.dart` @@ -311,7 +309,7 @@ class ELinuxUpgradeCommandRunner { /// Source: [updatePackages] in `upgrade.dart` Future updatePackages() async { globals.printStatus(''); - final String projectRoot = findProjectRoot(globals.fs); + final String? projectRoot = findProjectRoot(globals.fs); if (projectRoot != null) { globals.printStatus(''); await pub.get( diff --git a/lib/elinux_build_target.dart b/lib/elinux_build_target.dart index 40dc062..04b8cfb 100644 --- a/lib/elinux_build_target.dart +++ b/lib/elinux_build_target.dart @@ -1,11 +1,9 @@ -// Copyright 2022 Sony Group Corporation. All rights reserved. +// Copyright 2023 Sony Group Corporation. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2014 The Flutter Authors. All rights reserved. // 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:io'; import 'package:flutter_tools/src/artifacts.dart'; @@ -29,7 +27,6 @@ import 'package:flutter_tools/src/project.dart'; import 'elinux_builder.dart'; import 'elinux_cmake_project.dart'; -import 'elinux_plugins.dart'; /// Prepares the pre-built flutter bundle. /// @@ -67,7 +64,7 @@ abstract class ELinuxAssetBundle extends Target { throw MissingDefineException(kBuildMode, name); } final BuildMode buildMode = - getBuildModeForName(environment.defines[kBuildMode]); + getBuildModeForName(environment.defines[kBuildMode]!); final Directory outputDirectory = environment.outputDir .childDirectory('flutter_assets') ..createSync(recursive: true); @@ -111,7 +108,7 @@ abstract class ELinuxAssetBundle extends Target { /// Source: [DebugAndroidApplication] in `android.dart` class DebugELinuxApplication extends ELinuxAssetBundle { - DebugELinuxApplication(ELinuxBuildInfo buildInfo) : super(buildInfo); + DebugELinuxApplication(super.buildInfo); @override String get name => 'debug_elinux_application'; @@ -142,7 +139,7 @@ class DebugELinuxApplication extends ELinuxAssetBundle { /// See: [ReleaseAndroidApplication] in `android.dart` class ReleaseELinuxApplication extends ELinuxAssetBundle { - ReleaseELinuxApplication(ELinuxBuildInfo buildInfo) : super(buildInfo); + ReleaseELinuxApplication(super.buildInfo); @override String get name => 'release_elinux_application'; @@ -150,7 +147,9 @@ class ReleaseELinuxApplication extends ELinuxAssetBundle { @override List get dependencies => [ ...super.dependencies, - ELinuxAotElf(), + ELinuxAotElf(buildInfo.targetArch == 'arm64' + ? TargetPlatform.linux_arm64 + : TargetPlatform.linux_x64), ELinuxPlugins(buildInfo), ]; } @@ -191,20 +190,23 @@ class ELinuxPlugins extends Target { /// /// Source: [AotElfRelease] in `common.dart` class ELinuxAotElf extends AotElfBase { - ELinuxAotElf(); + const ELinuxAotElf(this.targetPlatform); @override String get name => 'elinux_aot_elf'; @override List get inputs => [ + const Source.pattern( + '{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/common.dart'), const Source.pattern('{BUILD_DIR}/app.dill'), - const Source.hostArtifact(HostArtifact.engineDartBinary), + const Source.artifact(Artifact.engineDartBinary), const Source.artifact(Artifact.skyEnginePath), - // Any type of gen_snapshot is applicable here because engine artifacts - // are assumed to be updated at once, not one by one for each platform - // or build mode. - const Source.artifact(Artifact.genSnapshot, mode: BuildMode.release), + Source.artifact( + Artifact.genSnapshot, + platform: targetPlatform, + mode: BuildMode.release, + ), ]; @override @@ -216,13 +218,15 @@ class ELinuxAotElf extends AotElfBase { List get dependencies => const [ KernelSnapshot(), ]; + + final TargetPlatform targetPlatform; } class NativeBundle { NativeBundle(this.buildInfo, this.targetFile); - final ELinuxBuildInfo buildInfo; - final String targetFile; + final ELinuxBuildInfo? buildInfo; + final String? targetFile; final ProcessUtils _processUtils = ProcessUtils( logger: globals.logger, processManager: globals.processManager); @@ -234,9 +238,9 @@ class NativeBundle { // Clean up the intermediate and output directories. final Directory eLinuxDir = eLinuxProject.editableDirectory; - final BuildMode buildMode = buildInfo.buildInfo.mode; + final BuildMode buildMode = buildInfo!.buildInfo.mode; final Directory outputDir = environment.outputDir - .childDirectory(buildInfo.targetArch) + .childDirectory(buildInfo!.targetArch) .childDirectory(buildMode.toString()); if (outputDir.existsSync()) { outputDir.deleteSync(recursive: true); @@ -264,20 +268,20 @@ class NativeBundle { // Copy necessary files final Directory engineDir = - _getEngineArtifactsDirectory(buildInfo.targetArch, buildMode); + _getEngineArtifactsDirectory(buildInfo!.targetArch, buildMode); final Directory commonDir = engineDir.parent.childDirectory('elinux-common'); final File engineBinary = engineDir.childFile('libflutter_engine.so'); // libflutter_elinux_*.so in profile mode is under the debug mode's directory. final Directory embedderDir = _getEngineArtifactsDirectory( - buildInfo.targetArch, + buildInfo!.targetArch, buildMode.isRelease ? buildMode : BuildMode.fromName('debug')); final File embedder = - embedderDir.childFile(buildInfo.targetBackendType == 'gbm' + embedderDir.childFile(buildInfo!.targetBackendType == 'gbm' ? 'libflutter_elinux_gbm.so' - : buildInfo.targetBackendType == 'eglstream' + : buildInfo!.targetBackendType == 'eglstream' ? 'libflutter_elinux_eglstream.so' - : buildInfo.targetBackendType == 'x11' + : buildInfo!.targetBackendType == 'x11' ? 'libflutter_elinux_x11.so' : 'libflutter_elinux_wayland.so'); final Directory clientWrapperDir = @@ -302,9 +306,6 @@ class NativeBundle { // Copy necessary files. { - if (flutterEphemeralDir.existsSync()) { - flutterEphemeralDir.deleteSync(recursive: true); - } flutterEphemeralDir.createSync(recursive: true); flutterEphemeralDir .childDirectory('cpp_client_wrapper') @@ -335,41 +336,40 @@ class NativeBundle { // Build the environment that needs to be set for the re-entrant flutter build // step. { - final Map environment = { - if (targetFile != null) 'FLUTTER_TARGET': targetFile, - ...buildInfo.buildInfo.toEnvironmentConfig(), - }; - if (globals.artifacts is LocalEngineArtifacts) { - final LocalEngineArtifacts localEngineArtifacts = - globals.artifacts as LocalEngineArtifacts; - final String engineOutPath = localEngineArtifacts.engineOutPath; - environment['FLUTTER_ENGINE'] = + final Map environmentConfig = + buildInfo!.buildInfo.toEnvironmentConfig(); + environmentConfig['FLUTTER_TARGET'] = targetFile!; + final LocalEngineInfo? localEngineInfo = + globals.artifacts?.localEngineInfo; + if (localEngineInfo != null) { + final String engineOutPath = localEngineInfo.engineOutPath; + environmentConfig['FLUTTER_ENGINE'] = globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath)); - environment['LOCAL_ENGINE'] = globals.fs.path.basename(engineOutPath); + environmentConfig['LOCAL_ENGINE'] = localEngineInfo.localEngineName; } - writeGeneratedCmakeConfig( - Cache.flutterRoot, eLinuxProject, buildInfo.buildInfo, environment); - await refreshELinuxPluginsList(eLinuxProject.parent); + writeGeneratedCmakeConfig(Cache.flutterRoot!, eLinuxProject, + buildInfo!.buildInfo, environmentConfig); } // Run the native build. final String cmakeBuildType = buildMode.isPrecompiled ? 'Release' : 'Debug'; final String targetArch = - buildInfo.targetArch == 'arm64' ? 'aarch64' : 'x86_64'; + buildInfo!.targetArch == 'arm64' ? 'aarch64' : 'x86_64'; final String hostArch = _getCurrentHostPlatformArchName(); - final String targetCompilerTriple = buildInfo.targetCompilerTriple; - final String targetSysroot = buildInfo.targetSysroot; - final String targetCompilerFlags = buildInfo.targetCompilerFlags; - final String targetToolchain = buildInfo.targetToolchain; - final String systemIncludeDirectories = buildInfo.systemIncludeDirectories; + final String? targetCompilerTriple = buildInfo!.targetCompilerTriple; + final String targetSysroot = buildInfo!.targetSysroot; + final String? targetCompilerFlags = buildInfo!.targetCompilerFlags; + final String? targetToolchain = buildInfo!.targetToolchain; + final String? systemIncludeDirectories = + buildInfo!.systemIncludeDirectories; RunResult result = await _processUtils.run( [ 'cmake', '-DCMAKE_BUILD_TYPE=$cmakeBuildType', - '-DFLUTTER_TARGET_BACKEND_TYPE=${buildInfo.targetBackendType}', - '-DFLUTTER_TARGET_PLATFORM=elinux-${buildInfo.targetArch}', + '-DFLUTTER_TARGET_BACKEND_TYPE=${buildInfo!.targetBackendType}', + '-DFLUTTER_TARGET_PLATFORM=elinux-${buildInfo!.targetArch}', if (targetSysroot != '/') '-DCMAKE_SYSROOT=$targetSysroot', - if (buildInfo.targetArch != hostArch) + if (buildInfo!.targetArch != hostArch) '-DCMAKE_SYSTEM_PROCESSOR=$targetArch', if (systemIncludeDirectories != null) '-DFLUTTER_SYSTEM_INCLUDE_DIRECTORIES=$systemIncludeDirectories', @@ -394,9 +394,9 @@ class NativeBundle { throwToolExit('Failed to cmake:\n$result'); } - final procResult = await Process.run('nproc', []); + final ProcessResult procResult = await Process.run('nproc', []); - final numProc = procResult.stdout.toString().trim(); + final String numProc = procResult.stdout.toString().trim(); result = await _processUtils.run( [ @@ -470,13 +470,13 @@ String getUnixPath(String path) { /// On Windows, appends the msys2 executables directory to PATH and returns. String getDefaultPathVariable() { final Map variables = globals.platform.environment; - return variables.containsKey('PATH') ? variables['PATH'] : ''; + return variables.containsKey('PATH') ? variables['PATH']! : ''; } /// See: [CachedArtifacts._getEngineArtifactsPath] -Directory _getEngineArtifactsDirectory(String arch, BuildMode mode) { +Directory _getEngineArtifactsDirectory(String arch, BuildMode? mode) { assert(mode != null, 'Need to specify a build mode.'); return globals.cache .getArtifactDirectory('engine') - .childDirectory('elinux-$arch-${mode.name}'); + .childDirectory('elinux-$arch-${mode!.name}'); } diff --git a/lib/elinux_builder.dart b/lib/elinux_builder.dart index fc5bc3f..4f74969 100644 --- a/lib/elinux_builder.dart +++ b/lib/elinux_builder.dart @@ -1,11 +1,9 @@ -// Copyright 2021 Sony Group Corporation. All rights reserved. +// Copyright 2023 Sony Group Corporation. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2014 The Flutter Authors. All rights reserved. // 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:convert'; import 'package:file/file.dart'; @@ -23,7 +21,6 @@ import 'package:flutter_tools/src/commands/build_ios_framework.dart'; import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/linux/build_linux.dart'; import 'package:flutter_tools/src/project.dart'; -import 'package:meta/meta.dart'; import 'elinux_build_target.dart'; import 'elinux_cmake_project.dart'; @@ -35,24 +32,23 @@ const String kTargetBackendType = 'TargetBackendType'; class ELinuxBuildInfo { const ELinuxBuildInfo( this.buildInfo, { - @required this.targetArch, - @required this.targetBackendType, - @required this.targetCompilerTriple, - @required this.targetSysroot, - @required this.targetCompilerFlags, - @required this.targetToolchain, - @required this.systemIncludeDirectories, - }) : assert(targetArch != null), - assert(targetBackendType != null); + required this.targetArch, + required this.targetBackendType, + required this.targetCompilerTriple, + required this.targetSysroot, + required this.targetCompilerFlags, + required this.targetToolchain, + required this.systemIncludeDirectories, + }); final BuildInfo buildInfo; final String targetArch; final String targetBackendType; - final String targetCompilerTriple; + final String? targetCompilerTriple; final String targetSysroot; - final String targetCompilerFlags; - final String targetToolchain; - final String systemIncludeDirectories; + final String? targetCompilerFlags; + final String? targetToolchain; + final String? systemIncludeDirectories; } // ignore: avoid_classes_with_only_static_members @@ -64,10 +60,10 @@ class ELinuxBuildInfo { /// - [buildLinux] in `build_linux.dart` (code size) class ELinuxBuilder { static Future buildBundle({ - @required FlutterProject project, - @required ELinuxBuildInfo eLinuxBuildInfo, - @required String targetFile, - SizeAnalyzer sizeAnalyzer, + required FlutterProject project, + required ELinuxBuildInfo eLinuxBuildInfo, + required String targetFile, + SizeAnalyzer? sizeAnalyzer, }) async { final ELinuxProject elinuxProject = ELinuxProject.fromFlutter(project); if (!elinuxProject.existsSync()) { @@ -100,14 +96,12 @@ class ELinuxBuilder { ...buildInfo.toBuildSystemEnvironment(), kTargetBackendType: eLinuxBuildInfo.targetBackendType, }, - inputs: { - kBundleSkSLPath: buildInfo.bundleSkSLPath, - }, - artifacts: globals.artifacts, + artifacts: globals.artifacts!, fileSystem: globals.fs, logger: globals.logger, processManager: globals.processManager, platform: globals.platform, + usage: globals.flutterUsage, ); final Target target = buildInfo.isDebug @@ -151,7 +145,7 @@ class ELinuxBuilder { final File precompilerTrace = globals.fs .directory(buildInfo.codeSizeDirectory) .childFile('trace.$genSnapshotPlatform.json'); - final Map output = await sizeAnalyzer.analyzeAotSnapshot( + final Map output = await sizeAnalyzer.analyzeAotSnapshot( aotSnapshot: codeSizeFile, // This analysis is only supported for release builds. outputDirectory: globals.fs.directory( @@ -212,6 +206,7 @@ String _getTargetPlatformPlatformName(TargetPlatform targetPlatform) { return 'linux-x64'; case TargetPlatform.android_arm64: return 'android-arm64'; + // ignore: no_default_cases default: return 'android-x64'; } diff --git a/lib/elinux_cmake_project.dart b/lib/elinux_cmake_project.dart index ded9fd3..e2f055d 100644 --- a/lib/elinux_cmake_project.dart +++ b/lib/elinux_cmake_project.dart @@ -3,8 +3,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:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/project.dart'; diff --git a/lib/elinux_device.dart b/lib/elinux_device.dart index 8409cd2..e532afd 100644 --- a/lib/elinux_device.dart +++ b/lib/elinux_device.dart @@ -3,8 +3,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:io'; @@ -20,7 +18,6 @@ import 'package:flutter_tools/src/device_port_forwarder.dart'; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/protocol_discovery.dart'; -import 'package:meta/meta.dart'; import 'package:process/process.dart'; import 'elinux_builder.dart'; @@ -32,15 +29,15 @@ import 'elinux_remote_device_config.dart'; /// See: [DesktopDevice] in `desktop_device.dart` class ELinuxDevice extends Device { ELinuxDevice( - String id, { - @required ELinuxRemoteDeviceConfig config, - @required bool desktop, - @required String backendType, - @required String targetArch, + super.id, { + required ELinuxRemoteDeviceConfig? config, + required bool desktop, + required String backendType, + required String targetArch, String sdkNameAndVersion = '', - @required Logger logger, - @required ProcessManager processManager, - @required OperatingSystemUtils operatingSystemUtils, + required Logger logger, + required ProcessManager processManager, + required OperatingSystemUtils operatingSystemUtils, }) : _config = config, _desktop = desktop, _backendType = backendType, @@ -54,18 +51,18 @@ class ELinuxDevice extends Device { portForwarder = config != null && config.usesPortForwarding ? CustomDevicePortForwarder( deviceName: config.label, - forwardPortCommand: config.forwardPortCommand, - forwardPortSuccessRegex: config.forwardPortSuccessRegex, + forwardPortCommand: config.forwardPortCommand!, + forwardPortSuccessRegex: config.forwardPortSuccessRegex!, processManager: processManager, logger: logger, ) : const NoOpDevicePortForwarder(), - super(id, + super( category: desktop ? Category.desktop : Category.mobile, platformType: PlatformType.custom, ephemeral: true); - final ELinuxRemoteDeviceConfig _config; + final ELinuxRemoteDeviceConfig? _config; final bool _desktop; final String _backendType; final String _targetArch; @@ -77,14 +74,14 @@ class ELinuxDevice extends Device { final Set _runningProcesses = {}; final ELinuxLogReader _logReader = ELinuxLogReader(); - int _forwardedHostPort; + int? _forwardedHostPort; BuildMode _buildMode = BuildMode.debug; @override Future get isLocalEmulator async => false; @override - Future get emulatorId async => null; + Future get emulatorId async => null; @override Future get targetPlatform async { @@ -108,44 +105,47 @@ class ELinuxDevice extends Device { String get name => 'eLinux'; @override - Future isAppInstalled(ELinuxApp app, {String userIdentifier}) async { + Future isAppInstalled(covariant ELinuxApp app, + {String? userIdentifier}) async { return false; } @override - Future isLatestBuildInstalled(ELinuxApp app) async { + Future isLatestBuildInstalled(covariant ELinuxApp app) async { return false; } @override - Future installApp(ELinuxApp app, {String userIdentifier}) async { - if (!await tryUninstall(appName: app.name)) { + Future installApp(covariant ELinuxApp app, + {String? userIdentifier}) async { + if (!await tryUninstall(appName: app.name!)) { return false; } final String bundlePath = app.outputDirectory(_buildMode, _targetArch); final bool result = - await tryInstall(localPath: bundlePath, appName: app.name); + await tryInstall(localPath: bundlePath, appName: app.name!); return result; } @override - Future uninstallApp(ELinuxApp app, {String userIdentifier}) async { - return tryUninstall(appName: app.name); + Future uninstallApp(covariant ELinuxApp app, + {String? userIdentifier}) async { + return tryUninstall(appName: app.name!); } /// Source: [AndroidDevice.startApp] in `android_device.dart` @override Future startApp( ELinuxApp package, { - String mainPath, - String route, - DebuggingOptions debuggingOptions, - Map platformArgs, + String? mainPath, + String? route, + DebuggingOptions? debuggingOptions, + Map platformArgs = const {}, bool prebuiltApplication = false, bool ipv6 = false, - String userIdentifier, + String? userIdentifier, }) async { if (!_desktop) { if (!await installApp(package)) { @@ -153,15 +153,15 @@ class ELinuxDevice extends Device { } final List interpolated = interpolateCommand( - _config.runDebugCommand, - {'remotePath': '/tmp/', 'appName': package.name}); + _config!.runDebugCommand, + {'remotePath': '/tmp/', 'appName': package.name!}); - _logger.printStatus('Launch $package.name on ${_config.id}'); + _logger.printStatus('Launch $package.name on ${_config!.id}'); final Process process = await _processManager.start(interpolated); - final ProtocolDiscovery discovery = ProtocolDiscovery.observatory( + final ProtocolDiscovery discovery = ProtocolDiscovery.vmService( _logReader, - portForwarder: _config.usesPortForwarding ? portForwarder : null, + portForwarder: _config!.usesPortForwarding ? portForwarder : null, hostPort: debuggingOptions?.hostVmServicePort, devicePort: debuggingOptions?.deviceVmServicePort, logger: _logger, @@ -170,11 +170,11 @@ class ELinuxDevice extends Device { _logReader.initializeProcess(process); - final Uri observatoryUri = await discovery.uri; + final Uri? observatoryUri = await discovery.uri; await discovery.cancel(); - if (_config.usesPortForwarding) { - _forwardedHostPort = observatoryUri.port; + if (_config!.usesPortForwarding) { + _forwardedHostPort = observatoryUri!.port; } return LaunchResult.succeeded(observatoryUri: observatoryUri); @@ -185,27 +185,27 @@ class ELinuxDevice extends Device { _logger.printTrace('Building app'); await buildForDevice( package, - buildInfo: debuggingOptions.buildInfo, + buildInfo: debuggingOptions!.buildInfo, mainPath: mainPath, ); } // Ensure that the executable is locatable. - final BuildMode buildMode = debuggingOptions?.buildInfo?.mode; - final bool traceStartup = platformArgs['trace-startup'] as bool ?? false; + final BuildMode buildMode = debuggingOptions!.buildInfo.mode; + final bool traceStartup = platformArgs['trace-startup'] as bool? ?? false; final String executable = executablePathForDevice(package, buildMode); const String executableOptions = '--bundle=./'; - if (executable == null) { - _logger.printError('Unable to find executable to run'); - return LaunchResult.failed(); - } + //if (executable == null) { + // _logger.printError('Unable to find executable to run'); + // return LaunchResult.failed(); + //} final Process process = await _processManager.start( [ executable, executableOptions, if (_desktop && _backendType == 'wayland') '-d', - ...?debuggingOptions?.dartEntrypointArgs, + ...debuggingOptions.dartEntrypointArgs, ], environment: _computeEnvironment(debuggingOptions, traceStartup, route), ); @@ -213,19 +213,18 @@ class ELinuxDevice extends Device { unawaited(process.exitCode.then((_) => _runningProcesses.remove(process))); _logReader.initializeProcess(process); - if (debuggingOptions?.buildInfo?.isRelease == true) { + if (debuggingOptions.buildInfo.isRelease == true) { return LaunchResult.succeeded(); } - final ProtocolDiscovery observatoryDiscovery = - ProtocolDiscovery.observatory( + final ProtocolDiscovery observatoryDiscovery = ProtocolDiscovery.vmService( _logReader, - devicePort: debuggingOptions?.deviceVmServicePort, - hostPort: debuggingOptions?.hostVmServicePort, + devicePort: debuggingOptions.deviceVmServicePort, + hostPort: debuggingOptions.hostVmServicePort, ipv6: ipv6, logger: _logger, ); try { - final Uri observatoryUri = await observatoryDiscovery.uri; + final Uri? observatoryUri = await observatoryDiscovery.uri; if (observatoryUri != null) { onAttached(package, buildMode, process); return LaunchResult.succeeded(observatoryUri: observatoryUri); @@ -243,7 +242,8 @@ class ELinuxDevice extends Device { } @override - Future stopApp(ELinuxApp app, {String userIdentifier}) async { + Future stopApp(covariant ELinuxApp? app, + {String? userIdentifier}) async { _maybeUnforwardPort(); bool succeeded = true; @@ -260,7 +260,7 @@ class ELinuxDevice extends Device { @override FutureOr getLogReader({ - ELinuxApp app, + covariant ELinuxApp? app, bool includePastLogs = false, }) => _logReader; @@ -285,14 +285,14 @@ class ELinuxDevice extends Device { Future buildForDevice( ELinuxApp package, { - String mainPath, - BuildInfo buildInfo, + String? mainPath, + BuildInfo? buildInfo, }) async { final FlutterProject project = FlutterProject.current(); // TODO(hidenori): change the fixed values (|targetSysroot|, |systemIncludeDirectories| and |targetCompilerTriple|) // to the values from user-specified custom-devices feilds. final ELinuxBuildInfo eLinuxBuildInfo = ELinuxBuildInfo( - buildInfo, + buildInfo!, targetArch: _targetArch, targetBackendType: _backendType, targetCompilerTriple: null, @@ -303,7 +303,7 @@ class ELinuxDevice extends Device { ); await ELinuxBuilder.buildBundle( project: project, - targetFile: mainPath, + targetFile: mainPath!, eLinuxBuildInfo: eLinuxBuildInfo, ); package = ELinuxApp.fromELinuxProject(project); @@ -317,7 +317,7 @@ class ELinuxDevice extends Device { /// Source: [DesktopDevice._computeEnvironment] in `desktop_device.dart` Map _computeEnvironment( - DebuggingOptions debuggingOptions, bool traceStartup, String route) { + DebuggingOptions debuggingOptions, bool traceStartup, String? route) { int flags = 0; final Map environment = {}; @@ -401,22 +401,22 @@ class ELinuxDevice extends Device { /// Source: [tryUninstall] in `custom_device.dart` Future tryUninstall( - {@required String appName, - Duration timeout, + {required String appName, + Duration? timeout, Map additionalReplacementValues = const {}}) async { - if (_config == null || _config.uninstallCommand == null) { + if (_config == null || _config!.uninstallCommand.isEmpty) { // do nothing if uninstall command is not defined. _logger.printTrace('uninstall command is not defined.'); return true; } final List interpolated = interpolateCommand( - _config.uninstallCommand, {'appName': appName}, + _config!.uninstallCommand, {'appName': appName}, additionalReplacementValues: additionalReplacementValues); try { - _logger.printStatus('Uninstall $appName from ${_config.id}.'); + _logger.printStatus('Uninstall $appName from ${_config!.id}.'); await _processUtils.run(interpolated, throwOnError: true, timeout: timeout); _logger.printStatus('Uninstallation Success'); @@ -430,17 +430,18 @@ class ELinuxDevice extends Device { /// Source: [tryInstall] in `custom_device.dart` Future tryInstall( - {@required String localPath, - @required String appName, - Duration timeout, + {required String localPath, + required String appName, + Duration? timeout, Map additionalReplacementValues = const {}}) async { - final List interpolated = interpolateCommand(_config.installCommand, + final List interpolated = interpolateCommand( + _config!.installCommand, {'localPath': localPath, 'appName': appName}, additionalReplacementValues: additionalReplacementValues); try { - _logger.printStatus('Install $appName ($localPath) to ${_config.id}'); + _logger.printStatus('Install $appName ($localPath) to ${_config!.id}'); await _processUtils.run(interpolated, throwOnError: true, timeout: timeout); _logger.printStatus('Installation Success'); diff --git a/lib/elinux_device_discovery.dart b/lib/elinux_device_discovery.dart index be4927d..53edc3c 100644 --- a/lib/elinux_device_discovery.dart +++ b/lib/elinux_device_discovery.dart @@ -4,8 +4,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:io'; import 'package:flutter_tools/src/android/android_workflow.dart'; @@ -23,7 +21,6 @@ import 'package:flutter_tools/src/fuchsia/fuchsia_workflow.dart'; import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/macos/macos_workflow.dart'; import 'package:flutter_tools/src/windows/windows_workflow.dart'; -import 'package:meta/meta.dart'; import 'package:process/process.dart'; import 'elinux_device.dart'; @@ -40,19 +37,19 @@ class ELinuxDeviceManager extends FlutterDeviceManager { processManager: globals.processManager, platform: globals.platform, androidSdk: globals.androidSdk, - iosSimulatorUtils: globals.iosSimulatorUtils, + iosSimulatorUtils: globals.iosSimulatorUtils!, featureFlags: featureFlags, fileSystem: globals.fs, - iosWorkflow: globals.iosWorkflow, - artifacts: globals.artifacts, + iosWorkflow: globals.iosWorkflow!, + artifacts: globals.artifacts!, flutterVersion: globals.flutterVersion, - androidWorkflow: androidWorkflow, - fuchsiaWorkflow: fuchsiaWorkflow, - xcDevice: globals.xcdevice, + androidWorkflow: androidWorkflow!, + fuchsiaWorkflow: fuchsiaWorkflow!, + xcDevice: globals.xcdevice!, userMessages: globals.userMessages, - windowsWorkflow: windowsWorkflow, - macOSWorkflow: context.get(), - fuchsiaSdk: globals.fuchsiaSdk, + windowsWorkflow: windowsWorkflow!, + macOSWorkflow: context.get()!, + fuchsiaSdk: globals.fuchsiaSdk!, operatingSystemUtils: globals.os, customDevicesConfig: CustomDevicesConfig( fileSystem: globals.fs, @@ -62,7 +59,7 @@ class ELinuxDeviceManager extends FlutterDeviceManager { ); final ELinuxDeviceDiscovery _eLinuxDeviceDiscovery = ELinuxDeviceDiscovery( - eLinuxWorkflow: eLinuxWorkflow, + eLinuxWorkflow: eLinuxWorkflow!, logger: globals.logger, processManager: globals.processManager, ); @@ -77,9 +74,9 @@ class ELinuxDeviceManager extends FlutterDeviceManager { /// Device discovery for eLinux devices. class ELinuxDeviceDiscovery extends PollingDeviceDiscovery { ELinuxDeviceDiscovery({ - @required ELinuxWorkflow eLinuxWorkflow, - @required ProcessManager processManager, - @required Logger logger, + required ELinuxWorkflow eLinuxWorkflow, + required ProcessManager processManager, + required Logger logger, }) : _eLinuxWorkflow = eLinuxWorkflow, _logger = logger, _processManager = processManager, @@ -105,7 +102,7 @@ class ELinuxDeviceDiscovery extends PollingDeviceDiscovery { bool get canListAnything => _eLinuxWorkflow.canListDevices; @override - Future> pollingGetDevices({Duration timeout}) async { + Future> pollingGetDevices({Duration? timeout}) async { if (!canListAnything) { return const []; } @@ -119,11 +116,11 @@ class ELinuxDeviceDiscovery extends PollingDeviceDiscovery { desktop: true, targetArch: _getCurrentHostPlatformArchName(), backendType: 'wayland', - logger: _logger ?? globals.logger, - processManager: _processManager ?? globals.processManager, + logger: _logger, + processManager: _processManager, operatingSystemUtils: OperatingSystemUtils( fileSystem: globals.fs, - logger: _logger ?? globals.logger, + logger: _logger, platform: globals.platform, processManager: const LocalProcessManager(), )), @@ -134,11 +131,11 @@ class ELinuxDeviceDiscovery extends PollingDeviceDiscovery { desktop: true, targetArch: _getCurrentHostPlatformArchName(), backendType: 'x11', - logger: _logger ?? globals.logger, - processManager: _processManager ?? globals.processManager, + logger: _logger, + processManager: _processManager, operatingSystemUtils: OperatingSystemUtils( fileSystem: globals.fs, - logger: _logger ?? globals.logger, + logger: _logger, platform: globals.platform, processManager: const LocalProcessManager(), )), @@ -163,18 +160,18 @@ class ELinuxDeviceDiscovery extends PollingDeviceDiscovery { } if (result.exitCode == 0 && - stdout.contains(remoteDevice.pingSuccessRegex)) { + stdout.contains(remoteDevice.pingSuccessRegex!)) { final ELinuxDevice device = ELinuxDevice(remoteDevice.id, config: remoteDevice, desktop: false, - targetArch: remoteDevice.platform, - backendType: remoteDevice.backend, + targetArch: remoteDevice.platform!, + backendType: remoteDevice.backend!, sdkNameAndVersion: remoteDevice.sdkNameAndVersion, - logger: _logger ?? globals.logger, - processManager: _processManager ?? globals.processManager, + logger: _logger, + processManager: _processManager, operatingSystemUtils: OperatingSystemUtils( fileSystem: globals.fs, - logger: _logger ?? globals.logger, + logger: _logger, platform: globals.platform, processManager: const LocalProcessManager(), )); diff --git a/lib/elinux_doctor.dart b/lib/elinux_doctor.dart index 1de4cfe..5f966f7 100644 --- a/lib/elinux_doctor.dart +++ b/lib/elinux_doctor.dart @@ -1,10 +1,8 @@ -// Copyright 2022 Sony Group Corporation. All rights reserved. +// Copyright 2023 Sony Group Corporation. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // 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:io'; import 'package:flutter_tools/src/base/context.dart'; @@ -13,12 +11,11 @@ import 'package:flutter_tools/src/base/user_messages.dart'; import 'package:flutter_tools/src/base/version.dart'; import 'package:flutter_tools/src/doctor.dart'; import 'package:flutter_tools/src/doctor_validator.dart'; -import 'package:meta/meta.dart'; import 'package:process/process.dart'; -ELinuxWorkflow get eLinuxWorkflow => context.get(); -ELinuxValidator get eLinuxValidator => context.get(); +ELinuxWorkflow? get eLinuxWorkflow => context.get(); +ELinuxValidator? get eLinuxValidator => context.get(); /// See: [_DefaultDoctorValidatorsProvider] in `doctor.dart` class ELinuxDoctorValidatorsProvider implements DoctorValidatorsProvider { @@ -28,7 +25,7 @@ class ELinuxDoctorValidatorsProvider implements DoctorValidatorsProvider { DoctorValidatorsProvider.defaultInstance.validators; return [ validators.first, - eLinuxValidator, + eLinuxValidator!, ...validators.sublist(1) ]; } @@ -36,28 +33,28 @@ class ELinuxDoctorValidatorsProvider implements DoctorValidatorsProvider { @override List get workflows => [ ...DoctorValidatorsProvider.defaultInstance.workflows, - eLinuxWorkflow, + eLinuxWorkflow!, ]; } /// See: [_VersionInfo] in `linux_doctor.dart` class _VersionInfo { _VersionInfo(this.description) { - final String versionString = RegExp(r'[0-9]+\.[0-9]+(?:\.[0-9]+)?') + final String? versionString = RegExp(r'[0-9]+\.[0-9]+(?:\.[0-9]+)?') .firstMatch(description) ?.group(0); number = Version.parse(versionString); } String description; - Version number; + Version? number; } /// See: [LinuxDoctorValidator] in `linux_doctor.dart` class ELinuxValidator extends DoctorValidator { ELinuxValidator({ - @required ProcessManager processManager, - @required UserMessages userMessages, + required ProcessManager processManager, + required UserMessages userMessages, }) : _processManager = processManager, _userMessages = userMessages, super('eLinux toolchain - develop for embedded Linux devices'); @@ -85,10 +82,11 @@ class ELinuxValidator extends DoctorValidator { @override Future validate() async { - ValidationType validationType = ValidationType.installed; + ValidationType validationType = ValidationType.success; final List messages = []; - final Map installedVersions = { + final Map installedVersions = + { // Sort the check to make the call order predictable for unit tests. for (String binary in _requiredBinaryVersions.keys.toList()..sort()) binary: await _getBinaryVersion(binary) @@ -96,23 +94,24 @@ class ELinuxValidator extends DoctorValidator { // Determine overall validation level. if (installedVersions.values - .any((_VersionInfo versionInfo) => versionInfo?.number == null)) { + .any((_VersionInfo? versionInfo) => versionInfo?.number == null)) { validationType = ValidationType.missing; } else if (installedVersions.keys.any((String binary) => - installedVersions[binary].number < _requiredBinaryVersions[binary])) { + installedVersions[binary]!.number! < + _requiredBinaryVersions[binary]!)) { validationType = ValidationType.partial; } // Message for Clang. { - final _VersionInfo version = installedVersions[kClangBinary]; + final _VersionInfo? version = installedVersions[kClangBinary]; if (version == null || version.number == null) { messages.add(ValidationMessage.error(_userMessages.clangMissing)); } else { assert(_requiredBinaryVersions.containsKey(kClangBinary)); messages.add(ValidationMessage(version.description)); - final Version requiredVersion = _requiredBinaryVersions[kClangBinary]; - if (version.number < requiredVersion) { + final Version requiredVersion = _requiredBinaryVersions[kClangBinary]!; + if (version.number! < requiredVersion) { messages.add(ValidationMessage.error( _userMessages.clangTooOld(requiredVersion.toString()))); } @@ -121,14 +120,14 @@ class ELinuxValidator extends DoctorValidator { // Message for CMake. { - final _VersionInfo version = installedVersions[kCmakeBinary]; + final _VersionInfo? version = installedVersions[kCmakeBinary]; if (version == null || version.number == null) { messages.add(ValidationMessage.error(_userMessages.cmakeMissing)); } else { assert(_requiredBinaryVersions.containsKey(kCmakeBinary)); messages.add(ValidationMessage(version.description)); - final Version requiredVersion = _requiredBinaryVersions[kCmakeBinary]; - if (version.number < requiredVersion) { + final Version requiredVersion = _requiredBinaryVersions[kCmakeBinary]!; + if (version.number! < requiredVersion) { messages.add(ValidationMessage.error( _userMessages.cmakeTooOld(requiredVersion.toString()))); } @@ -137,7 +136,7 @@ class ELinuxValidator extends DoctorValidator { // Message for pkg-config. { - final _VersionInfo version = installedVersions[kPkgConfigBinary]; + final _VersionInfo? version = installedVersions[kPkgConfigBinary]; if (version == null || version.number == null) { messages.add(ValidationMessage.error(_userMessages.pkgConfigMissing)); } else { @@ -146,8 +145,8 @@ class ELinuxValidator extends DoctorValidator { messages.add(ValidationMessage( _userMessages.pkgConfigVersion(version.description))); final Version requiredVersion = - _requiredBinaryVersions[kPkgConfigBinary]; - if (version.number < requiredVersion) { + _requiredBinaryVersions[kPkgConfigBinary]!; + if (version.number! < requiredVersion) { messages.add(ValidationMessage.error( _userMessages.pkgConfigTooOld(requiredVersion.toString()))); } @@ -174,8 +173,8 @@ class ELinuxValidator extends DoctorValidator { } /// See: [_getBinaryVersion] in `linux_doctor.dart` - Future<_VersionInfo> _getBinaryVersion(String binary) async { - ProcessResult result; + Future<_VersionInfo?> _getBinaryVersion(String binary) async { + ProcessResult? result; try { result = await _processManager.run([ binary, @@ -183,6 +182,8 @@ class ELinuxValidator extends DoctorValidator { ]); } on ArgumentError { // ignore error. + } on ProcessException { + // ignore error. } if (result == null || result.exitCode != 0) { return null; @@ -193,7 +194,7 @@ class ELinuxValidator extends DoctorValidator { /// See: [_libraryIsPresent] in `linux_doctor.dart` Future _libraryIsPresent(String library) async { - ProcessResult result; + ProcessResult? result; try { result = await _processManager.run([ 'pkg-config', @@ -212,7 +213,7 @@ class ELinuxValidator extends DoctorValidator { /// See: [AndroidWorkflow] in `android_workflow.dart` class ELinuxWorkflow extends Workflow { ELinuxWorkflow({ - @required OperatingSystemUtils operatingSystemUtils, + required OperatingSystemUtils operatingSystemUtils, }) : _operatingSystemUtils = operatingSystemUtils; final OperatingSystemUtils _operatingSystemUtils; diff --git a/lib/elinux_package.dart b/lib/elinux_package.dart index 645dc01..9a1baa2 100644 --- a/lib/elinux_package.dart +++ b/lib/elinux_package.dart @@ -1,10 +1,8 @@ -// Copyright 2021 Sony Group Corporation. All rights reserved. +// Copyright 2023 Sony Group Corporation. All rights reserved. // Copyright 2014 The Flutter Authors. All rights reserved. // 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:file/file.dart'; import 'package:flutter_tools/src/application_package.dart'; import 'package:flutter_tools/src/base/file_system.dart'; @@ -13,7 +11,6 @@ import 'package:flutter_tools/src/cmake.dart'; import 'package:flutter_tools/src/flutter_application_package.dart'; import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/project.dart'; -import 'package:meta/meta.dart'; import 'elinux_cmake_project.dart'; @@ -28,10 +25,10 @@ class ELinuxApplicationPackageFactory extends FlutterApplicationPackageFactory { ); @override - Future getPackageForPlatform( + Future getPackageForPlatform( TargetPlatform platform, { - BuildInfo buildInfo, - File applicationBinary, + BuildInfo? buildInfo, + File? applicationBinary, }) async { if (platform == TargetPlatform.tester) { return applicationBinary == null @@ -44,7 +41,7 @@ class ELinuxApplicationPackageFactory extends FlutterApplicationPackageFactory { } abstract class ELinuxApp extends ApplicationPackage { - ELinuxApp({@required String projectBundleId}) : super(id: projectBundleId); + ELinuxApp({required String projectBundleId}) : super(id: projectBundleId); factory ELinuxApp.fromELinuxProject(FlutterProject project) { return BuildableELinuxApp( @@ -69,8 +66,8 @@ abstract class ELinuxApp extends ApplicationPackage { class PrebuiltELinuxApp extends ELinuxApp { PrebuiltELinuxApp({ - @required String executable, - @required String outputDirectory, + required String executable, + required String outputDirectory, }) : _executable = executable, _outputDirectory = outputDirectory, super(projectBundleId: executable); @@ -90,14 +87,14 @@ class PrebuiltELinuxApp extends ELinuxApp { } class BuildableELinuxApp extends ELinuxApp { - BuildableELinuxApp({@required this.project}) + BuildableELinuxApp({required this.project}) : super(projectBundleId: project.parent.manifest.appName); final ELinuxProject project; @override String executable(BuildMode buildMode, String targetArch) { - final String binaryName = getCmakeExecutableName(project); + final String? binaryName = getCmakeExecutableName(project); return globals.fs.path.join( 'build/elinux/', targetArch, diff --git a/lib/elinux_plugins.dart b/lib/elinux_plugins.dart index fe84fa8..596021b 100644 --- a/lib/elinux_plugins.dart +++ b/lib/elinux_plugins.dart @@ -1,11 +1,9 @@ -// Copyright 2022 Sony Group Corporation. All rights reserved. +// Copyright 2023 Sony Group Corporation. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2014 The Flutter Authors. All rights reserved. // 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:convert'; import 'package:file/file.dart'; @@ -23,7 +21,6 @@ import 'package:flutter_tools/src/plugins.dart'; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart'; -import 'package:meta/meta.dart'; import 'package:package_config/package_config.dart'; import 'package:path/path.dart' as path; import 'package:yaml/yaml.dart'; @@ -33,8 +30,8 @@ import 'elinux_cmake_project.dart'; /// Source: [LinuxPlugin] in `platform_plugins.dart` class ELinuxPlugin extends PluginPlatform implements NativeOrDartPlugin { ELinuxPlugin({ - @required this.name, - @required this.directory, + required this.name, + required this.directory, this.pluginClass, this.dartPluginClass, this.ffiPlugin, @@ -49,24 +46,21 @@ class ELinuxPlugin extends PluginPlatform implements NativeOrDartPlugin { List dependencies) { assert(validate(yaml)); // Treat 'none' as not present. See https://github.com/flutter/flutter/issues/57497. - String pluginClass = yaml[kPluginClass] as String; + String? pluginClass = yaml[kPluginClass] as String; if (pluginClass == 'none') { pluginClass = null; } return ELinuxPlugin( name: name, directory: directory, - pluginClass: yaml[kPluginClass] as String, - dartPluginClass: yaml[kDartPluginClass] as String, - ffiPlugin: yaml[kFfiPlugin] as bool, - defaultPackage: yaml[kDefaultPackage] as String, + pluginClass: yaml[kPluginClass] as String?, + dartPluginClass: yaml[kDartPluginClass] as String?, + ffiPlugin: yaml[kFfiPlugin] as bool?, + defaultPackage: yaml[kDefaultPackage] as String?, dependencies: dependencies); } static bool validate(YamlMap yaml) { - if (yaml == null) { - return false; - } return yaml[kPluginClass] is String || yaml[kDartPluginClass] is String || yaml[kFfiPlugin] == true || @@ -77,11 +71,11 @@ class ELinuxPlugin extends PluginPlatform implements NativeOrDartPlugin { final String name; final Directory directory; - final String pluginClass; - final String dartPluginClass; - final List dependencies; - final bool ffiPlugin; - final String defaultPackage; + final String? pluginClass; + final String? dartPluginClass; + final List? dependencies; + final bool? ffiPlugin; + final String? defaultPackage; @override bool hasMethodChannel() => pluginClass != null; @@ -97,9 +91,9 @@ class ELinuxPlugin extends PluginPlatform implements NativeOrDartPlugin { return { 'name': name, if (pluginClass != null) 'class': pluginClass, - if (pluginClass != null) 'filename': _filenameForCppClass(pluginClass), + if (pluginClass != null) 'filename': _filenameForCppClass(pluginClass!), if (dartPluginClass != null) 'dartPluginClass': dartPluginClass, - if (ffiPlugin != null && ffiPlugin) kFfiPlugin: true, + if (ffiPlugin != null && ffiPlugin!) kFfiPlugin: true, if (defaultPackage != null) kDefaultPackage: defaultPackage, }; } @@ -116,12 +110,12 @@ String _filenameForCppClass(String className) { /// See: [FlutterCommand.verifyThenRunCommand] in `flutter_command.dart` mixin ELinuxExtension on FlutterCommand { - String _entrypoint; + String? _entrypoint; bool get _usesTargetOption => argParser.options.containsKey('target'); @override - Future verifyThenRunCommand(String commandPath) async { + Future verifyThenRunCommand(String? commandPath) async { if (super.shouldRunPub) { // TODO(swift-kim): Should run pub get first before injecting plugins. await ensureReadyForELinuxTooling(FlutterProject.current()); @@ -164,7 +158,7 @@ Future _createEntrypoint( final LanguageVersion languageVersion = determineLanguageVersion( globals.fs.file(targetFile), packageConfig[flutterProject.manifest.appName], - Cache.flutterRoot, + Cache.flutterRoot!, ); final Uri mainUri = globals.fs.file(targetFile).absolute.uri; @@ -261,7 +255,7 @@ bool _writeELinuxFlutterPluginsListLegacy( flutterPluginsBuffer .write('${plugin.name}=${globals.fsUtils.escapePath(plugin.path)}\n'); } - final String oldPluginFileContent = _readFileContent(pluginsFile); + final String? oldPluginFileContent = _readFileContent(pluginsFile); final String pluginFileContent = flutterPluginsBuffer.toString(); pluginsFile.writeAsStringSync(pluginFileContent, flush: true); @@ -361,7 +355,7 @@ List> _filterELinuxPluginsByPlatform( _kFlutterPluginsNameKey: plugin.name, _kFlutterPluginsPathKey: globals.fsUtils.escapePath(plugin.path), _kFlutterPluginsDependenciesKey: [ - ...plugin.dependencies.where(pluginNames.contains) + ...plugin.dependencies!.where(pluginNames.contains) ], }); } @@ -379,7 +373,7 @@ List _createPluginLegacyDependencyGraph(List plugins) { 'name': plugin.name, // Extract the plugin dependencies which happen to be plugins. 'dependencies': [ - ...plugin.dependencies.where(pluginNames.contains) + ...plugin.dependencies!.where(pluginNames.contains) ], }); } @@ -429,7 +423,7 @@ Future> findELinuxPlugins( ); for (final Package package in packageConfig.packages) { final Uri packageRoot = package.packageUriRoot.resolve('..'); - final ELinuxPlugin plugin = _pluginFromPackage(package.name, packageRoot); + final ELinuxPlugin? plugin = _pluginFromPackage(package.name, packageRoot); if (plugin == null) { continue; } else if (nativeOnly && @@ -444,7 +438,7 @@ Future> findELinuxPlugins( } /// Source: [_pluginFromPackage] in `plugins.dart` -ELinuxPlugin _pluginFromPackage(String name, Uri packageRoot) { +ELinuxPlugin? _pluginFromPackage(String name, Uri packageRoot) { final String pubspecPath = globals.fs.path.fromUri(packageRoot.resolve('pubspec.yaml')); if (!globals.fs.isFileSync(pubspecPath)) { @@ -469,11 +463,11 @@ ELinuxPlugin _pluginFromPackage(String name, Uri packageRoot) { globals.printTrace('Found plugin $name at ${packageDir.path}'); final YamlMap pluginYaml = flutterConfig['plugin'] as YamlMap; - if (pluginYaml == null || pluginYaml['platforms'] == null) { + if (pluginYaml['platforms'] == null) { return null; } final YamlMap platformsYaml = pluginYaml['platforms'] as YamlMap; - if (platformsYaml == null || platformsYaml[ELinuxPlugin.kConfigKey] == null) { + if (platformsYaml[ELinuxPlugin.kConfigKey] == null) { return null; } final YamlMap dependencies = pubspec['dependencies'] as YamlMap; @@ -481,9 +475,7 @@ ELinuxPlugin _pluginFromPackage(String name, Uri packageRoot) { name, packageDir.childDirectory('elinux'), platformsYaml[ELinuxPlugin.kConfigKey] as YamlMap, - dependencies == null - ? [] - : [...dependencies.keys.cast()], + [...dependencies.keys.cast()], ); } @@ -627,29 +619,29 @@ void _renderTemplateToFile(String template, dynamic context, String filePath) { /// Source: [createPluginSymlinks] in `flutter_plugins.dart` void createPluginSymlinks(FlutterProject project, {bool force = false}) { - Map platformPlugins; - final String pluginFileContent = + Map? platformPlugins; + final String? pluginFileContent = _readFileContent(project.flutterPluginsDependenciesFile); if (pluginFileContent != null) { - final Map pluginInfo = - json.decode(pluginFileContent) as Map; + final Map? pluginInfo = + json.decode(pluginFileContent) as Map?; platformPlugins = - pluginInfo[_kFlutterPluginsPluginListKey] as Map; + pluginInfo?[_kFlutterPluginsPluginListKey] as Map?; } - platformPlugins ??= {}; + platformPlugins ??= {}; final ELinuxProject eLinuxProject = ELinuxProject.fromFlutter(project); if (eLinuxProject.existsSync()) { _createPlatformPluginSymlinks( eLinuxProject.pluginSymlinkDirectory, - platformPlugins[eLinuxProject.pluginConfigKey] as List, + platformPlugins[eLinuxProject.pluginConfigKey] as List?, force: force, ); } } /// Returns the contents of [File] or [null] if that file does not exist. -String _readFileContent(File file) { +String? _readFileContent(File file) { return file.existsSync() ? file.readAsStringSync() : null; } @@ -657,7 +649,7 @@ String _readFileContent(File file) { /// /// If [force] is true, the directory will be created only if missing. void _createPlatformPluginSymlinks( - Directory symlinkDirectory, List platformPlugins, + Directory symlinkDirectory, List? platformPlugins, {bool force = false}) { if (force && symlinkDirectory.existsSync()) { // Start fresh to avoid stale links. @@ -667,10 +659,10 @@ void _createPlatformPluginSymlinks( if (platformPlugins == null) { return; } - for (final Map pluginInfo - in platformPlugins.cast>()) { - final String name = pluginInfo[_kFlutterPluginsNameKey] as String; - final String path = pluginInfo[_kFlutterPluginsPathKey] as String; + for (final Map pluginInfo + in platformPlugins.cast>()) { + final String name = pluginInfo[_kFlutterPluginsNameKey]! as String; + final String path = pluginInfo[_kFlutterPluginsPathKey]! as String; final Link link = symlinkDirectory.childLink(name); if (link.existsSync()) { continue; @@ -678,6 +670,7 @@ void _createPlatformPluginSymlinks( try { link.createSync(path); } on FileSystemException catch (e) { + // ignore: invalid_use_of_visible_for_testing_member handleSymlinkException(e, platform: globals.platform, os: globals.os, diff --git a/lib/executable.dart b/lib/executable.dart index 99320ba..d732787 100644 --- a/lib/executable.dart +++ b/lib/executable.dart @@ -4,8 +4,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:io'; import 'package:flutter_tools/executable.dart' as flutter; @@ -88,11 +86,11 @@ Future main(List args) async { DevicesCommand(verboseHelp: verboseHelp), DoctorCommand(verbose: verbose), EmulatorsCommand(), - FormatCommand(verboseHelp: verbose), + FormatCommand(), GenerateLocalizationsCommand( fileSystem: globals.fs, logger: globals.logger, - artifacts: globals.artifacts, + artifacts: globals.artifacts!, processManager: globals.processManager, ), InstallCommand(verboseHelp: verboseHelp),