AndroidChromeSafariBrowser class

Class that provides a visible standard interface for browsing the web. It presents a self-contained web interface inside your app.

If you need to customize or interact with the web content, use the InAppWebView widget.

This class uses native Chrome Custom Tabs on Android and SFSafariViewController on iOS.

NOTE: If you want to use the ChromeSafariBrowser class on Android 11+ you need to specify your app querying for android.support.customtabs.action.CustomTabsService in your AndroidManifest.xml (you can read more about it here: https://developers.google.com/web/android/custom-tabs/best-practices#applications_targeting_android_11_api_level_30_or_above).

Officially Supported Platforms/Implementations:

  • Android
  • iOS
Inheritance
  • Object
  • PlatformInterface
  • AndroidChromeSafariBrowser

Constructors

AndroidChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams params)
Constructs a AndroidChromeSafariBrowser.
AndroidChromeSafariBrowser.static()
Provide static access.
factory

Properties

eventHandler ↔ PlatformChromeSafariBrowserEvents?
Event handler object that handles the PlatformChromeSafariBrowser events.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
id String
View ID used internally.
final
params → PlatformChromeSafariBrowserCreationParams
The parameters used to initialize the PlatformChromeSafariBrowser.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addMenuItem(ChromeSafariBrowserMenuItem menuItem) → void
Adds a ChromeSafariBrowserMenuItem to the menu.
addMenuItems(List<ChromeSafariBrowserMenuItem> menuItems) → void
Adds a list of ChromeSafariBrowserMenuItem to the menu.
clearWebsiteData() Future<void>
Clear associated website data accrued from browsing activity within your app. This includes all local storage, cached resources, and cookies.
inherited
close() Future<void>
Closes the PlatformChromeSafariBrowser instance.
dispose() → void
Disposes the channel and event handler.
getMaxToolbarItems() Future<int>
The maximum number of allowed secondary toolbar items.
getPackageName({List<String>? packages, bool ignoreDefault = false}) Future<String?>
Returns the preferred package to use for Custom Tabs. The preferred package name is the default VIEW intent handler as long as it supports Custom Tabs. To modify this preferred behavior, set ignoreDefault to true and give a non empty list of package names in packages. This method queries the PackageManager to determine which packages support the Custom Tabs API. On apps that target Android 11 and above, this requires adding the following package visibility elements to your manifest.
invalidatePrewarmingToken(PrewarmingToken prewarmingToken) Future<void>
Ends all prewarmed connections associated with the token, except for connections that are also kept alive by other tokens.
inherited
isAvailable() Future<bool>
On Android, returns true if Chrome Custom Tabs is available. On iOS, returns true if SFSafariViewController is available. Otherwise returns false.
isEngagementSignalsApiAvailable() Future<bool>
Returns whether the Engagement Signals API is available. The availability of the Engagement Signals API may change at runtime. If an EngagementSignalsCallback has been set, an PlatformChromeSafariBrowserEvents.onSessionEnded signal will be sent if the API becomes unavailable later.
isOpened() bool
Returns true if the PlatformChromeSafariBrowser instance is opened, otherwise false.
launchUrl({required WebUri url, Map<String, String>? headers, List<WebUri>? otherLikelyURLs, WebUri? referrer}) Future<void>
Tells the browser to launch with url.
mayLaunchUrl({WebUri? url, List<WebUri>? otherLikelyURLs}) Future<bool>
Tells the browser of a likely future navigation to a URL. The most likely URL has to be specified first. Optionally, a list of other likely URLs can be provided. They are treated as less likely than the first one, and have to be sorted in decreasing priority order. These additional URLs may be ignored. All previous calls to this method will be deprioritized.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
open({WebUri? url, Map<String, String>? headers, List<WebUri>? otherLikelyURLs, WebUri? referrer, ChromeSafariBrowserClassOptions? options, ChromeSafariBrowserSettings? settings}) Future<void>
Opens the PlatformChromeSafariBrowser instance with an url.
postMessage(String message) Future<CustomTabsPostMessageResultType>
Sends a postMessage request using the origin communicated via requestPostMessageChannel. Fails when called before PlatformChromeSafariBrowserEvents.onMessageChannelReady event.
prewarmConnections(List<WebUri> URLs) Future<PrewarmingToken?>
Prewarms a connection to each URL. SFSafariViewController will automatically use a prewarmed connection if possible when loading its initial URL.
inherited
requestPostMessageChannel({required WebUri sourceOrigin, WebUri? targetOrigin}) Future<bool>
Sends a request to create a two way postMessage channel between the client and the browser. If you want to specifying the target origin to communicate with, set the targetOrigin.
setActionButton(ChromeSafariBrowserActionButton actionButton) → void
Set a custom action button.
setSecondaryToolbar(ChromeSafariBrowserSecondaryToolbar secondaryToolbar) → void
Sets the remote views displayed in the secondary toolbar in a custom tab.
toString() String
A string representation of this object.
inherited
updateActionButton({required Uint8List icon, required String description}) Future<void>
Updates the ChromeSafariBrowserActionButton.icon and ChromeSafariBrowserActionButton.description.
updateSecondaryToolbar(ChromeSafariBrowserSecondaryToolbar secondaryToolbar) Future<void>
Sets or updates (if already present) the Remote Views of the secondary toolbar in an existing custom tab session.
validateRelationship({required CustomTabsRelationType relation, required WebUri origin}) Future<bool>
Requests to validate a relationship between the application and an origin.

Operators

operator ==(Object other) bool
The equality operator.
inherited