onLaunch function

Future<bool> onLaunch(
  1. String urlString, {
  2. BaseLaunchMode mode = BaseLaunchMode.platformDefault,
  3. WebViewConfiguration webViewConfiguration = const urlLauncher.WebViewConfiguration(),
  4. String? webOnlyWindowName,
})

鸿蒙默认使用系统浏览器或对应应用打开,避免依赖宿主额外注册 WebView 页面。 显式指定应用内模式时,仍需按鸿蒙插件说明配置页面和路由。

Implementation

Future<bool> onLaunch(
  String urlString, {
  BaseLaunchMode mode = BaseLaunchMode.platformDefault,
  urlLauncher.WebViewConfiguration webViewConfiguration =
      const urlLauncher.WebViewConfiguration(),
  String? webOnlyWindowName,
}) =>
    urlLauncher.launchUrl(Uri.parse(urlString),
        mode: isOhos && mode == BaseLaunchMode.platformDefault
            ? BaseLaunchMode.externalApplication
            : mode,
        webViewConfiguration: webViewConfiguration,
        webOnlyWindowName: webOnlyWindowName);