openBrowser function
Opens the given url in the system's default web browser.
This function supports:
- macOS: uses the
opencommand - Windows: uses the
startcommand withrunInShell: true - Linux: uses the
xdg-opencommand
Example:
openBrowser('https://pub.dev');
Note: This function assumes the appropriate system commands (open, start, or xdg-open)
are available in the system's PATH.
Implementation
void openBrowser(String url) {
if (Platform.isMacOS) {
Process.run('open', [url]);
} else if (Platform.isWindows) {
Process.run('start', [url], runInShell: true);
} else if (Platform.isLinux) {
Process.run('xdg-open', [url]);
}
}