blob: ca9d8e1c9175b204288664602bfdd90f852f598f [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
/// 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.
enum PreferredLaunchMode {
/// Leaves the decision of how to launch the URL to the platform
/// implementation.
/// Loads the URL in an in-app web view (e.g., Android Custom Tabs, Safari View Controller).
/// Passes the URL to the OS to be handled by another application.
/// Passes the URL to the OS to be handled by another non-browser application.
/// Additional configuration options for [PreferredLaunchMode.inAppWebView].
/// Not all options are supported on all platforms. This is a superset of
/// available options exposed across all implementations.
class InAppWebViewConfiguration {
/// Creates a new WebViewConfiguration with the given settings.
const InAppWebViewConfiguration({
this.enableJavaScript = true,
this.enableDomStorage = true,
this.headers = const <String, String>{},
/// Whether or not JavaScript is enabled for the web content.
final bool enableJavaScript;
/// Whether or not DOM storage is enabled for the web content.
final bool enableDomStorage;
/// Additional headers to pass in the load request.
final Map<String, String> headers;
/// Options for [launchUrl].
class LaunchOptions {
/// Creates a new parameter object with the given options.
const LaunchOptions({
this.mode = PreferredLaunchMode.platformDefault,
this.webViewConfiguration = const InAppWebViewConfiguration(),
/// The requested launch mode.
final PreferredLaunchMode mode;
/// Configuration for the web view in [PreferredLaunchMode.inAppWebView] mode.
final InAppWebViewConfiguration webViewConfiguration;
/// A web-platform-specific option to set the link target.
/// Default behaviour when unset should be to open the url in a new tab.
final String? webOnlyWindowName;