flutter_native_web 1.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 93

flutter_native_web #

Native WebView as a widget in flutter

Inline WebView in flutter using AndroidView and UiKitView

Supported #

  • Android
  • iOS

Note

  • Keypad is not working (No Support by flutter)
  • Don't use inside scrollview
  • onPageStarted, onPageFinished Only works with Android

Screenshot #

Screenshot

How to Use #

dependencies:
  flutter_native_web: "^1.0.3"

import 'package:flutter_native_web/flutterwebview.dart';


WebController webController;

FlutterWebView flutterWebView = new FlutterWebView(
  onWebCreated: onWebCreated,
);
 new Container(
    child: flutterWebViewString,
    height: 300.0,
    width: 500.0,
 ),
void onWebCreated(webController) {
    this.webController = webController;
    this.webController.loadUrl("https://facebook.com");
    this.webController.onPageStarted.listen((url) =>
        print("Loading $url")
    );
    this.webController.onPageFinished.listen((url) =>
        print("Finished loading $url")
    );
}

or #

String html = '<body>Hello world! <a href="www.html5rocks.com">HTML5 rocks!';

void onWebCreated(webController) {
    this.webController = webController;
    this.webController.loadData(html);
    this.webController.onPageStarted.listen((url) =>
        print("Loading $url")
    );
    this.webController.onPageFinished.listen((url) =>
        print("Finished loading $url")
    );
}

Android #

Ensure the following permission is present in your Android Manifest file, located in project /android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>

iOS #

Opt-in to the embedded views preview by adding a boolean property to the app's Info.plist file with the key io.flutter.embedded_views_preview and the value YES.

	<key>io.flutter.embedded_views_preview</key>
	<string>YES</string>

Coming soon #

  • JSInterface
  • more (suggest)

1.0.3 #

  • PR #19 Merged

1.0.1 #

  • bug fixes

1.0.1 #

  • loadData method iOS Support added

1.0.0 #

  • iOS Support Added

0.1.2 #

  • Initial release
  • Full html support
  • only android supported

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:flutter_native_web/flutter_native_web.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/foundation.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {

  WebController webController;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {

    FlutterNativeWeb flutterWebView = new FlutterNativeWeb(
      onWebCreated: onWebCreated,
      gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
                        Factory<OneSequenceGestureRecognizer>(
                          () => TapGestureRecognizer(),
                        ),
                      ].toSet(),
    );

    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Native WebView as Widget'),
        ),
        body: new SingleChildScrollView(
          child: new Column(
            children: <Widget>[
              new Text('Native WebView as Widget\n\n'),
              new Container(
                child: flutterWebView,
                height: 300.0,
                width: 500.0,
              ),
            ],
          ),
        )
      ),
    );
  }

  void onWebCreated(webController) {
    this.webController = webController;
    this.webController.loadUrl("https://flutter.io/");
    this.webController.onPageStarted.listen((url) =>
        print("Loading $url")
    );
    this.webController.onPageFinished.listen((url) =>
        print("Finished loading $url")
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_native_web: ^1.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_native_web/flutter_native_web.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
85
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
93
Learn more about scoring.

We analyzed this package on Apr 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/flutter_native_web.dart.

Run flutter format to format lib/flutter_native_web.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8