GithubHelp home page GithubHelp logo

ponnamkarthik / flutterwebview Goto Github PK

View Code? Open in Web Editor NEW
62.0 5.0 26.0 7.05 MB

Flutter Plugin that Renders Native Webview as a widget in flutter

License: Other

Java 31.62% Objective-C 28.19% Dart 24.47% Ruby 15.71%
flutter android dart

flutterwebview's Introduction

flutter_native_web

Native WebView as a widget in flutter

Inline WebView in flutter using AndroidView and UiKitView

Supported

  • Android
  • iOS

Note

  • onPageStarted, onPageFinished Only works with Android

Screenshot

Screenshot

How to Use

dependencies:
  flutter_native_web: "^1.0.2"
  
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)

flutterwebview's People

Contributors

peeto avatar ponnamkarthik avatar vjpranay avatar yinsee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

flutterwebview's Issues

Garbled characters appear on some android devices

Hi,we found the garbled characters appear on some android devices

so, i'm change the code to use
webView.loadDataWithBaseURL(null, html, "text/html", "utf-8",null);
to repleace this
webView.loadData(html, "text/html", "utf-8");
image

Compilation error PlatformViewFactory

C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_native_web-1.0.2\android\src\main\java\io\github\ponnamkarthik\flutterwebview\FlutterwebviewFactory.java:15: error: constructor PlatformViewFactory in class PlatformViewFactory cannot be applied to given types;
		super();
		^
  required: MessageCodec<Object>
  found: no arguments
  reason: actual and formal argument lists differ in length
Note: C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_native_web-1.0.2\android\src\main\java\io\github\ponnamkarthik\flutterwebview\FlutterWeb.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_native_web:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4m 14s
Finished with error: Gradle task assembleDebug failed with exit code 1

flutter doctor output

C:\flutter\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [versão 10.0.17134.523], locale pt-BR)
	• Flutter version 1.0.0 at C:\flutter\flutter
	• Framework revision 5391447fae (2 months ago), 2018-11-29 19:41:26 -0800
	• Engine revision 7375a0f414
	• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
	• Android SDK at C:\Users\Casa\AppData\Local\Android\sdk
	• Android NDK location not configured (optional; useful for native profiling support)
	• Platform android-28, build-tools 28.0.3
	• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
	• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
	• All Android licenses accepted.

[√] Android Studio (version 3.3)
	• Android Studio at C:\Program Files\Android\Android Studio
	• Flutter plugin version 32.0.1
	• Dart plugin version 182.5124
	• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[√] Connected device (1 available)
	• MS45S A6 • 45235829013292 • android-arm • Android 6.0 (API 23)

• No issues found!

WebView is not working, here is the error

E/BufferQueueProducer( 2730): [unnamed-2730-7] cancelBuffer: BufferQueue has been abandoned
Restarted application in 1,550ms.
W/art ( 2730): Attempt to remove local handle scope entry from IRT, ignoring
W/AwContents( 2730): onDetachedFromWindow called when already detached. Ignoring
W/art ( 2730): Attempt to remove local handle scope entry from IRT, ignoring
W/art ( 2730): Attempt to remove local handle scope entry from IRT, ignoring
I/flutter ( 2730): Page finished loading: http://www.baidu.com/
W/FlutterWebViewClient( 2730): Using a navigationDelegate with an old webview implementation, pages with frames or iframes will not work
I/flutter ( 2730): allowing navigation to NavigationRequest(url: https://m.baidu.com/?from=1013105i, isForMainFrame: true)
I/chromium( 2730): [INFO:CONSOLE(0)] "Mixed Content: The page at 'https://m.baidu.com/?from=1013105i' was loaded over HTTPS, but requested an insecure image 'http://127.0.0.1:59468/?data=fCMxIzsjMi8xLzUjLSMyIzsjdVppMVZCaHdSU3h5cUxNc1VFYnU3NDVrSWZVNmpUVkN3R3tVdHh6dkdYW0sxVjlDcjV0U0NxVXlmN2RuMDNEWDRILERbbEJweHlUWzlSRDB4cGUwMyx0VXpUUTI6MjhmRDlnLHFROnY2LHVDM3cxSGhCdGp7eU5qQ213ZEd1e1txVGJQMjNJRVtwdm1zWEh3MGJ2aERCPj4jLSMzIzsjMjEyNDIxNmp9MjEyNDIxNmojLSM0IzsyNjY4OTkyMzg4OjM3fg%3D%3D'. This request has been blocked; the content must be served over HTTPS.", source: https://m.baidu.com/?from=1013105i (0)
I/flutter ( 2730): Page finished loading: https://m.baidu.com/?from=1013105i
I/chromium( 2730): [INFO:CONSOLE(1)] "Uncaught TypeError: undefined is not a function", source: https://gss0.bdstatic.com/5bd1bjqh_Q23odCf/static/wiseindex/js/lib/transfer/common/Carousel_b2a7162.js (1)

doesn't compile in release mode

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':flutter_native_web:verifyReleaseResources'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
1 exception was raised by workers:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
C:\Users\USER.gradle\caches\transforms-2\files-2.1\a9ba6f49a6b87dabd208a845906a38df\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.

 C:\Users\USER\.gradle\caches\transforms-2\files-2.1\a9ba6f49a6b87dabd208a845906a38df\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.

Error while compiling

image
and as text:
(
C:\Work\flutter.pub-cache\hosted\pub.dartlang.org\flutter_native_web-0.1.2\android\src\main\java\io\github\ponnamkarthik\flutterwebview\FlutterwebviewFactory.java:10: error: no interface expected here
public class FlutterwebviewFactory extends PlatformViewFactory {
^
C:\Work\flutter.pub-cache\hosted\pub.dartlang.org\flutter_native_web-0.1.2\android\src\main\java\io\github\ponnamkarthik\flutterwebview\FlutterwebviewFactory.java:19: error: method does not override or implement a method from a supertype
@OverRide
^
C:\Work\flutter.pub-cache\hosted\pub.dartlang.org\flutter_native_web-0.1.2\android\src\main\java\io\github\ponnamkarthik\flutterwebview\FlutterwebviewPlugin.java:11: error: incompatible types: FlutterwebviewFactory cannot be converted to PlatformViewFactory
"ponnamkarthik/flutterwebview", new FlutterwebviewFactory(registrar));
^
Note: C:\Work\flutter.pub-cache\hosted\pub.dartlang.org\flutter_native_web-0.1.2\android\src\main\java\io\github\ponnamkarthik\flutterwebview\FlutterWeb.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
3 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':flutter_native_web:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

  • Get more help at https://help.gradle.org

BUILD FAILED in 7s
Finished with error: Gradle build failed: 1
)

Getting this when install this lib.

Is there any solutions?

WebView Plugin issue

For Android this library is working fine. but for iOS I am getting this exception.

══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════
flutter: The following MissingPluginException was thrown while activating platform stream on channel
flutter: ponnamkarthik/flutterwebview_stream_pagestart_0:
flutter: MissingPluginException(No implementation found for method listen on channel
flutter: ponnamkarthik/flutterwebview_stream_pagestart_0)
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7)
flutter:
flutter: #1 EventChannel.receiveBroadcastStream. (package:flutter/src/services/platform_channel.dart:504:29)
flutter:
flutter: #9 _AboutState.onWebCreated (package:wallet/ui/profile/about/about_page.dart:86:38)
flutter: #10 _FlutterNativeWebState.onPlatformCreated (package:flutter_native_web/flutter_native_web.dart:57:12)
flutter: #12 _FlutterNativeWebState.onPlatformCreated (package:flutter_native_web/flutter_native_web.dart:53:33)
flutter: #13 _UiKitViewState._createNewUiKitView (package:flutter/src/widgets/platform_view.dart:511:14)
flutter: #24 PlatformViewsService.initUiKitView (package:flutter/src/services/platform_views.dart)
flutter: #35 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart)
flutter: (elided 42 frames from package dart:async and package dart:async-patch)
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: MissingPluginException(No implementation found for method listen on channel ponnamkarthik/flutterwebview_stream_pagefinish_0)

flutterWebViewString, FlutterWebView are not imported

Hi guys,
Sorry i just started with Flutter/Dart.
From doc of this plugin, need to import next file:

import 'package:flutter_native_web/flutter_native_web.dart';

But it isn't found and Android Studio suggest to import

import 'package:flutter_native_web/flutter_native_web.dart';

So WebController is imported - OK, but some other params, like:
flutterWebViewString, FlutterWebView are not found, what i'm doing wrong?
Thanks.

http://prntscr.com/mr95gg

Compile warning

Note: /Users/amarjeetsinghmudhar/Development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_web-1.0.0/android/src/main/java/io/github/ponnamkarthik/flutterwebview/FlutterWeb.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

error

flutter_native_web-1.0.2/android/src/main/java/io/github/ponnamkarthik/flutterwebview/FlutterwebviewFactory.java:15: 错误: 无法将类 PlatformViewFactory中的构造器 PlatformViewFactory应用到给定类型;
super();
^
需要: MessageCodec
找到: 没有参数
原因: 实际参数列表和形式参数列表长度不同

JSInterface?

Can i know Information about javascript interface and handlinig back key for webview?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.