Search packages, repositories and app categories

Package detailsv0.7.4

web_browser

A web browser widget. Unlike webview_flutter, comes with cross-platform navigation and URL sharing widgets. Works in Android, iOS, browsers, and other platforms.

AndroidiOSmacOS
30-day downloads
100
Likes
71
Pub points
140

Install package

flutter pub add web_browser

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The web_browser package provides a cross-platform web browser widget for Flutter, offering built-in navigation controls and URL sharing functionality. Unlike webview_flutter, it is designed to work seamlessly across Android, iOS, macOS, and web platforms with consistent UI components. It simplifies embedding web content while maintaining platform-specific behaviors and user experience standards. The package includes intuitive navigation tools such as back/forward buttons and shareable URLs, making it ideal for apps requiring integrated browsing capabilities without reinventing common browser features.

Use cases

  • Embedding web content in mobile and desktop apps
  • Building app-based browsers with navigation
  • Sharing URLs from within the app
  • Creating hybrid web-native applications
  • Enabling in-app browsing on multiple platforms

Key features

  • Cross-platform compatibility (Android, iOS, macOS, web)
  • Built-in navigation controls
  • URL sharing integration
  • Consistent UI across platforms
  • Lightweight and easy to integrate

Suitable for

  • Developers building multiplatform apps with web content
  • Apps needing simple browser-like functionality
  • Projects requiring URL sharing from embedded web views
  • Teams wanting to avoid custom WebView implementations
  • Hybrid app developers seeking native-like browsing

Considerations

  • Limited customization compared to raw WebView
  • Depends on platform-specific rendering behavior
  • May require additional permissions on some platforms
  • Not suitable for complex web app hosting
  • Performance may vary on older devices

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Pub Package Github Actions CI

Overview

The package gives you Browser, a Flutter widget for displaying web pages.

The package is built on top of webview_flutter and it adds navigation widgets that:

  • Display the domain.
  • Allow user to tap "back", "forward", "refresh", or share the URL using a native dialog of each platform.
  • Display website loading error messages in a visually pleasant and easy-to-understand way.

Browser has been tested in Android, iOS, and browsers. By adding relevant "webview_flutter" plugin dependencies to your "pubspec.yaml", you can use this package in Windows, Mac OS X, and Linux too.

Licensed under the Apache License 2.0.

Links

Setting up

1.Setup

In pubspec.yaml:

dependencies:
  web_browser: ^0.7.4

2.Display web browser

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

void main() {
  runApp(const MaterialApp(
    home: Scaffold(
      body: SafeArea(
        child: Browser(
          initialUriString: 'https://flutter.dev/',
        ),
      ),
    ),
  ));
}

Manual

Default designs

The package contains two designs, Cupertino (web_browser.cupertino) and Material (web_browser.material). By default, the package chooses a Cupertino or Material design based on whether the app is CupertinoApp or MaterialApp. You can override the defaults by using relevant parameters of Browser() constructor.

The Cupertino and Material navigation bars look like this:

Localization

Use BrowserLocalizations to localize the widgets.

void main() {
  runApp(MaterialApp(
    localizations: [
      ...browserLocalizationsList,
      // ...
    ],
    // ...
  ));
}

final browserLocalizationsList = [
  // Spanish localization
  BrowserLocalizations.forLocale(
    locale: Locale('es'),
    load: (locale) async => BrowserLocalizations(
      couldNotReach: 'No se pudo acceder al sitio web.',
      // ...
    ),
  ),
];

Setting various parameters

You can give various parameters to Browser:

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

void main() {
  runApp(const MaterialApp(
    home: Scaffold(
      body: SafeArea(
        child: Browser(
          initialUriString: 'https://flutter.dev/',
          controller: BrowserController(
            // "User-Agent" HTTP header.
            userAgent: 'Your user agent',
            
            // Can user zoom into the content? Default is true.
            isZoomingEnabled: false,
          )
        ),
      ),
    ),
  ));
}

Cache clearing

For end-users privacy, it is good to clear:

  • Cookies
  • Caches
  • Local storage

You can enable this by setting:

import 'package:web_browser/web_browser.dart';

void main() {
  // Clear when the app is started
  BrowserController.resetGlobalStateAtStart = true;
  
  // Clear every now and then.
  BrowserController.globalStateExpiration = const Duration(days: 1);
  
  // ...
}

Accessing WebViewController

To access WebViewController by using browserController.webViewController.

Categories

Dependencies

Dependency list 6 items

Source repository

Projects using this package

No data available yet.