The ChromeSafariBrowser class represents Chrome Custom Tabs on Android and SFSafariViewController on iOS.

Note for Android: If you want to use the ChromeSafariBrowser class on Android 11+, then you need to specify your app querying for in your AndroidManifest.xml (you can read more about it here).

To be able to listen to the ChromeSafariBrowser events, you need to create a class that extends the ChromeSafariBrowser class in order to override the method callbacks.


import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';

class MyChromeSafariBrowser extends ChromeSafariBrowser {
  void onOpened() {
    print("ChromeSafari browser opened");

  void onCompletedInitialLoad() {
    print("ChromeSafari browser initial load completed");

  void onClosed() {
    print("ChromeSafari browser closed");

Future main() async {

  if (Platform.isAndroid) {
    await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true);

  runApp(MaterialApp(home: MyApp()));

class MyApp extends StatefulWidget {
  final ChromeSafariBrowser browser = new MyChromeSafariBrowser();

  _MyAppState createState() => new _MyAppState();

class _MyAppState extends State<MyApp> {
  void initState() {
    widget.browser.addMenuItem(new ChromeSafariBrowserMenuItem(
        id: 1,
        label: 'Custom item menu 1',
        action: (url, title) {
          print('Custom item menu 1 clicked!');

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('ChromeSafariBrowser Example'),
      body: Center(
        child: ElevatedButton(
            onPressed: () async {
                  url: Uri.parse(""),
                  options: ChromeSafariBrowserClassOptions(
                      android: AndroidChromeCustomTabsOptions(
                          addDefaultShareMenuItem: false),
                      ios: IOSSafariOptions(barCollapsingEnabled: true)));
            child: Text("Open Chrome Safari Browser")),

This is the result:

Android basic usage.
iOS basic usage.