Skip to content

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 ​

OptionDefaultMeaning
toolbarColorplatformBackground of the toolbar. Title and buttons switch between black and white to stay readable.
toolbarTitlepage titleFixed title instead of the title of the current page.
showUrlfalseShows the current URL under the title.
showNavigationButtonstrueShows back, forward and reload buttons.
closeButtonLabeliconText for the close button instead of the platform's close icon.
settingsWebViewSettings()Settings of the WebView in the browser, including android: and ios:.

Behaviour ​

  • One AdvancedInAppBrowser shows one browser at a time. open throws a StateError while it is open; after onClosed you can open it again.
  • The browser has its own WebView. Use loadUrl and evaluateJavaScript on the browser while it is open; both throw a StateError otherwise.
  • onLoadError reports main-page failures only, not failed images or scripts.
  • open fails with a PlatformException (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 UINavigationController modally. 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.incognito to 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 http and https URLs are accepted; anything else throws an ArgumentError.
  • isAvailable is always true on iOS. On Android it is true when an app can handle https links; open fails with a PlatformException (unavailable) otherwise, and with not-attached when the app has no screen to present from.
  • onClosed is 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.

Released under the MIT License.