installFlutterOnRemote method
Future<bool>
installFlutterOnRemote(
- String username,
- InternetAddress ip, {
- String? version,
- bool addHostToKnownHosts = true,
in install flutter in the remote machine using ssh connection
we will use snapp_installerhttps://github.com/Snapp-X/snapp_installer
to install flutter in the remote machine
returns true if snapp_installer installed successfully otherwise returns false
Implementation
Future<bool> installFlutterOnRemote(
String username,
InternetAddress ip, {
String? version,
bool addHostToKnownHosts = true,
}) async {
final snappInstallerPath = await findSnappInstallerPathInteractive(
username,
ip,
);
final RunResult result;
final versionArgs = version != null ? '-v $version -f' : '';
final installFlutterCommand = '$snappInstallerPath install -q $versionArgs';
logger.detail('Install Flutter Command: \n $installFlutterCommand');
try {
result = await processRunner.runWithOutput(
hostPlatform.sshCommand(
ipv6: ip.isIpv6,
sshTarget: ip.sshTarget(username),
lastCommand: true,
command: installFlutterCommand,
addHostToKnownHosts: addHostToKnownHosts,
),
processManager: processManager,
logger: logger,
);
} catch (e, s) {
logger.detail(
'Something went wrong while trying to install flutter on the remote. \n $e \n $s',
);
return false;
} finally {
logger.spaces();
}
if (result.exitCode != 0) {
logger.info('Flutter Installer ExitCode: ${result.exitCode}');
logger.info('Flutter Installer Stdout: ${result.stdout.trim()}');
logger.info('Flutter Installer Stderr: ${result.stderr}');
}
return result.exitCode == 0;
}