在用url_launcher插件打开网页的时候,发现在安卓上只是在当前应用内跳转到一个新的简陋浏览器页面。
但是一般我们“在浏览器中打开”都是完整地跳转外部浏览器去打开这个网页。
解决方法
研究了一下发现很好解决,指定启动模式就行了
launchUrlString(
'要打开的网页地址',
// 指定为在外部打开的模式
mode: LaunchMode.externalApplication,
);
好家伙加一行代码就解决
其它的启动模式如下,应该也用不上
/// The desired mode to launch a URL.
///
/// Support for these modes varies by platform. Platforms that do not support
/// the requested mode may substitute another mode. See [launchUrl] for more
/// details.
enum LaunchMode {
/// Leaves the decision of how to launch the URL to the platform
/// implementation.
platformDefault,
/// Loads the URL in an in-app web view (e.g., Android WebView).
inAppWebView,
/// Loads the URL in an in-app web view (e.g., Android Custom Tabs, SFSafariViewController).
inAppBrowserView,
/// Passes the URL to the OS to be handled by another application.
externalApplication,
/// Passes the URL to the OS to be handled by another non-browser application.
externalNonBrowserApplication,
}