web_browser 0.7.1 copy "web_browser: ^0.7.1" to clipboard
web_browser: ^0.7.1 copied to clipboard

A cross-platform Flutter widget for displaying websites and other web content. Has navigation Cupertino/Material buttons and takes care of complex platform differences.

Pub Package Github Actions CI

Overview #

Browser is a Flutter widget for browsing websites.

  • Works in Android, iOS, and browsers. Various cross-platform differences are handled correctly by the package so you don't need to deal with details of the underlying webview_flutter. You can still access
  • Has a customizable top bar that displays the domain so that end-users have some protection against phishing websites.
  • Has customizable bottom bar with buttons for "back", "forward", "refresh", and URL sharing.
  • Displays website loading error messages using Flutter widgets. The errors look nicer and are easier to decipher by non-technical users.

Licensed under the Apache License 2.0.

Setting up #

1.Setup #

In pubspec.yaml:

dependencies:
  web_browser: ^0.7.0

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 #

Designs available in this package #

The package contains two designs:

By default, the package chooses a Cupertino or Material design based on whether the app is CupertinoApp or MaterialApp.

The navigation buttons 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 user agent #

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(
            userAgent: 'Your user agent',
          )
        ),
      ),
    ),
  ));
}

Accessing WebViewController #

To access WebViewController by using browserController.webViewController.

70
likes
0
pub points
89%
popularity

Publisher

verified publisherdint.dev

A cross-platform Flutter widget for displaying websites and other web content. Has navigation Cupertino/Material buttons and takes care of complex platform differences.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cupertino_icons, flutter, share_plus, webview_flutter, webview_flutter_android, webview_flutter_web, webview_flutter_wkwebview

More

Packages that depend on web_browser