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

outdated

Widgets for showing web content. Uses webview_flutter in Android/iOS and HTML nodes in browsers.

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:universal_html/html.dart' as html;
import 'package:web_browser/web_browser.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp();

  @override
  State<StatefulWidget> createState() {
    return MyAppState();
  }
}

class MyAppState extends State<MyApp> {
  Widget _body;

  @override
  Widget build(BuildContext context) {
    _body ??= _buildBody(0);
    return MaterialApp(
      title: 'Example',
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
      ],
      home: Scaffold(
        body: SafeArea(child: _body),
        bottomNavigationBar: BottomNavigationBar(
          items: [
            BottomNavigationBarItem(
              icon: Icon(Icons.web),
              label: 'WebBrowser',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.slideshow),
              label: 'WebNode',
            ),
            BottomNavigationBarItem(
              icon: Icon(CupertinoIcons.settings),
              label: 'Settings',
            ),
          ],
          onTap: (i) {
            setState(() {
              _body = _buildBody(i);
            });
          },
        ),
      ),
    );
  }

  Widget _buildBody(int i) {
    return IndexedStack(
      index: i,
      children: [
        WebBrowser(
          key: ValueKey('browser'),
          initialUrl: 'https://dart.dev/',
        ),
        WebNode(
          key: ValueKey('node'),
          node: html.DivElement()
            ..style.textAlign = 'center'
            ..append(
              html.HeadingElement.h1()..appendText('Hello world!'),
            )
            ..append(html.AnchorElement()
              ..href = 'https://dart.dev/'
              ..appendText('A link to dart.dev')),
        ),
        Column(
          children: [
            // TODO: Settings for manual testing
          ],
        ),
      ],
    );
  }
}
70
likes
0
pub points
89%
popularity

Publisher

verified publisherdint.dev

Widgets for showing web content. Uses webview_flutter in Android/iOS and HTML nodes in browsers.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cupertino_icons, flutter, meta, share, universal_html, webview_flutter

More

Packages that depend on web_browser