openBrowser function
Opens url in the user's default browser.
Uses open on macOS, xdg-open on Linux, and start on Windows.
The result means "launch ATTEMPTED" (the command was invoked and exited 0), never "a browser window opened": SSH, headless, and wrong-default-profile sessions report true without anything the user can see. Callers must therefore never gate the authorization URL on this result — the OAuth/SSO flows print the URL in every outcome (gh-1450); this boolean only chooses the accompanying hint line.
Implementation
Future<bool> openBrowser(String url) async {
String executable;
List<String> args;
if (Platform.isMacOS) {
executable = 'open';
args = [url];
} else if (Platform.isLinux) {
executable = 'xdg-open';
args = [url];
} else if (Platform.isWindows) {
executable = 'start';
args = ['', url];
} else {
return false;
}
try {
final result = await Process.run(executable, args);
return result.exitCode == 0;
} on Object {
return false;
}
}