webOpen function

void webOpen(
  1. String url, [
  2. bool ask = false
])

Implementation

void webOpen(String url, [bool ask = false]){
  String plat = Platform.operatingSystem;
  String cmd = switch(plat){
      "android" => "xdg-open",
      "fuchsia" => "",
      "ios" => "",
      "windows" => "start",
      "linux" => "xdg-open",
      "macos" => "",
      _ => "",
    };
  if(ask){
    stdout.write("");
    String? res = stdin.readLineSync();
    if(res == null){
      webOpen(url, ask);
      return;
    }
    if(res.toLowerCase() != "y"){
      return;
    }
  }
  Process.runSync(cmd, <String>[url]);
}