In-app browser
AdvancedInAppBrowser opens a page in a full-screen native browser with a toolbar, over your Flutter UI. Use it for links that should leave your own screens without leaving the app.
dart
final browser = AdvancedInAppBrowser(
onOpened: () => debugPrint('opened'),
onClosed: () => debugPrint('closed'),
onPageFinished: (url) => debugPrint('loaded $url'),
onLoadError: (error) => debugPrint('failed: $error'),
);
await browser.open(
Uri.parse('https://example.com'),
options: const InAppBrowserOptions(
toolbarColor: Color(0xFF1E3A8A),
showUrl: true,
),
);
// Later:
await browser.close();Options
| Option | Default | Meaning |
|---|---|---|
toolbarColor | platform | Background of the toolbar. Title and buttons switch between black and white to stay readable. |
toolbarTitle | page title | Fixed title instead of the title of the current page. |
showUrl | false | Shows the current URL under the title. |
showNavigationButtons | true | Shows back, forward and reload buttons. |
closeButtonLabel | icon | Text for the close button instead of the platform's close icon. |
settings | WebViewSettings() | Settings of the WebView in the browser, including android: and ios:. |
Behaviour
- One
AdvancedInAppBrowsershows one browser at a time.openthrows aStateErrorwhile it is open; afteronClosedyou can open it again. - The browser has its own WebView. Use
loadUrlandevaluateJavaScripton the browser while it is open; both throw aStateErrorotherwise. onLoadErrorreports main-page failures only, not failed images or scripts.openfails with aPlatformException(not-attached) when the app has no screen to present from, for example while it is in the background.
Differences
- Android shows a dedicated
Activity. The back button goes back in the page first and closes the browser when there is nothing to go back to. Permission prompts and file choosers are shown over the browser. - iOS presents a
UINavigationControllermodally. The back, forward and reload buttons are in a bottom toolbar, and the close button is on the left of the navigation bar. - Cookies are shared with other WebViews on Android. On iOS, set
WebViewSettings.incognitoto isolate the browser's website data.
See Platform API mapping for the native APIs behind it.
System browser
AdvancedSystemBrowser opens a page in the system's own browser UI instead of a WebView of this plugin: Chrome Custom Tabs on Android and SFSafariViewController on iOS. The page runs in the user's browser, with its cookies, saved passwords and passkeys, and your app cannot read or script it. Use it for OAuth sign-in and other flows that should not run in an embedded WebView.
dart
final browser = AdvancedSystemBrowser(onClosed: () => debugPrint('closed'));
if (await browser.isAvailable()) {
await browser.open(
Uri.parse('https://example.com/login'),
options: const SystemBrowserOptions(toolbarColor: Color(0xFF1E3A8A)),
);
}- Only
httpandhttpsURLs are accepted; anything else throws anArgumentError. isAvailableis alwaystrueon iOS. On Android it istruewhen an app can handlehttpslinks;openfails with aPlatformException(unavailable) otherwise, and withnot-attachedwhen the app has no screen to present from.onClosedis reliable on iOS. Android's Custom Tabs report nothing when they close, so it is called when the app comes back to the foreground after the tab was shown, which also happens if the user returns by another route. Do not rely on it to mean the user finished signing in; check the result with your server.- It cannot be closed from Dart, and the page cannot be scripted. If you need either, use
AdvancedInAppBrowser.