bestForFlatpak method
Determines the best installation method for Flatpak.
The to parameter is the installation target.
Implementation
Future<String> bestForFlatpak({String to = 'install'}) async {
// @TODO: Add support for hasDefault and xSUDO and global update.
final methods = package.methods ?? [];
final hasMethod = methods.contains('flatpak');
final String? flatpak = await Executable('flatpak').find();
final String? bestFlatpak = flatpak;
if (hasMethod && bestFlatpak != null) {
Global.updateCommand =
"${Global.sudoPath} $bestFlatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo";
return '${to}_flatpak "${Global.sudoPath} $bestFlatpak -y --noninteractive"';
}
stopIfForcedMethodNotFound();
return await bestForAny(to: to);
}