provideEmbedderPath method
Implementation
@override
Future<String> provideEmbedderPath() async {
if (context.targetIp == null || context.username == null) {
throwToolExit(
'Target IP and username are required to provide the embedder path.');
}
final username = context.username!;
final targetIp = context.targetIp!;
final hostFlutterVersion =
FlutterSdkManager().flutterVersion.frameworkVersion;
final possibleFlutterPath =
await remoteControllerService.findFlutterPath(username, targetIp);
// if we found the flutter path on the remote machine
// then we need to check if the version of the remote flutter is the same as the host flutter
if (possibleFlutterPath != null) {
final remoteFlutterVersion =
await remoteControllerService.findFlutterVersion(
username,
targetIp,
possibleFlutterPath,
);
logger.detail('remote flutter version: $remoteFlutterVersion');
logger.detail('host flutter version: $hostFlutterVersion');
if (remoteFlutterVersion == hostFlutterVersion) {
logger.success(
'You have flutter installed on the remote machine with the same version as your host machine.');
logger.spaces();
return possibleFlutterPath;
} else {
return _fixConflictVersions(
username,
targetIp,
hostFlutterVersion,
remoteFlutterVersion!,
);
}
}
logger.info(
'Could not find flutter in the remote machine automatically. \n\n'
'We need the exact path of your flutter command line tools on the remote device. \n'
'Now you have two options: \n'
'1. You can enter the path to flutter manually. \n'
'2. We can install flutter on the remote machine for you. \n');
logger.spaces();
final provideFlutterPathOption = interaction.selectIndex(
'Please select one of the options:',
options: [
'Install Flutter on the remote machine',
'Enter Flutter path manually',
],
);
logger.spaces();
if (provideFlutterPathOption == 0) {
return _installFlutterOnRemote(username, targetIp, hostFlutterVersion);
}
return interaction.readFlutterManualPath();
}