Code Monkey home page Code Monkey logo

native_webview's Introduction

native_webview Pub Version

A Flutter plugin that allows you to add an inline WebView.

Motivation

There is already a useful library for working with WebViews in Flutter.

These libraries come with trade-offs such as simple implementation but lack features, or very advanced features and complex implementation.

native_webview is designed to provide users with a standard set of WebView features provided by iOS and Android while keeping the implementation simple.

Requirements

  • Dart: >=2.10.0 <3.0.0
  • Flutter: >=1.22.0 <2.0.0
  • Android: minSdkVersion 24, AndroidX, Kotlin, Chrome version >= 74.0.3729.185
  • iOS: iOS version >= 11.0, Xcode version >= 11, Swift

Getting Started

Usage

class InitialUrlScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Initial URL"),
      ),
      body: WebView(
        initialUrl: "https://flutter.dev",
      ),
    );
  }
}

If you want to see other examples, see example or see DartDoc.

Known issues

Run tests

  • There are tests in `example/integration_test/tests
  • You will need to launch the iOS simulator or Android emulator
make test

native_webview's People

Contributors

chuganzy avatar hisaichi5518 avatar kazu0620 avatar kitak 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

Watchers

 avatar  avatar  avatar  avatar

native_webview's Issues

Add gestureNavigationEnabled

Add gestureNavigationEnabled to the WebView.
If gestureNavigationEnabled is false, gesture navigation will not work.
This will only work on iOS, but the name will be unified with the API of webview_flutter.
flutter/plugins#2339

By default gestureNavigationEnabled is false.

shouldOverrideUrlLoadingを実装するとロードがキャンセルされる場合がある

https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20android.webkit.WebResourceRequest)

Note: Do not call WebView#loadUrl(String) with the request's URL and then return true. This unnecessarily cancels the current load and starts a new load with the same URL. The correct way to continue loading a given URL is to simply return false, without calling WebView#loadUrl(String).

とあるので、これが関係しているのかな?と考えているのですが、如何でしょうか?

試しにAndroidのネイティブアプリを作成し、shouldOverrideUrlLoadingreturn false するだけにしてみたところ、ロードがキャンセルされていたところが、正常に読み込まれました。

試しのアプリで以下の実装の場合、ロードがキャンセルされていました。
(returnの値はtrue / falseいずれを固定としても同様)

webView.loadUrl(request?.url.toString(), request?.requestHeaders ?: emptyMap())
return super.shouldOverrideUrlLoading(view, request);

まだ不確かな状態でのissueとなっておりますが、ご検討頂けると助かります

Sometimes the screen flickers when using WebView

 $ flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E287, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.1)
[✓] Android Studio (version 3.6)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.3.4)
[✓] VS Code (version 1.42.0)
[✓] Connected device (2 available)

• No issues found!

Attempt to read from field 'android.view.WindowManager$LayoutParams android.view.ViewRootImpl.mWindowAttributes' on a null object reference

Sometimes the app crashes.

D/AndroidRuntime( 8163): Shutting down VM
E/AndroidRuntime( 8163): FATAL EXCEPTION: main
E/AndroidRuntime( 8163): Process: ..., PID: 8163
E/AndroidRuntime( 8163): java.lang.NullPointerException: Attempt to read from field 'android.view.WindowManager$LayoutParams android.view.ViewRootImpl.mWindowAttributes' on a null object reference
E/AndroidRuntime( 8163): 	at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:1626)
E/AndroidRuntime( 8163): 	at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:1865)
E/AndroidRuntime( 8163): 	at android.view.inputmethod.InputMethodManager.isActive(InputMethodManager.java:1184)
E/AndroidRuntime( 8163): 	at com.hisaichi5518.native_webview.InputAwareWebView$1.run(InputAwareWebView.java:204)
E/AndroidRuntime( 8163): 	at android.os.Handler.handleCallback(Handler.java:883)
E/AndroidRuntime( 8163): 	at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime( 8163): 	at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime( 8163): 	at android.app.ActivityThread.main(ActivityThread.java:7356)
E/AndroidRuntime( 8163): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 8163): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime( 8163): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

I haven't found a way to recreate it.

java.lang.ClassCastException: $Proxy0 cannot be cast to android.view.WindowManagerImpl

The app crashes when I try to open Dropdown.

It does not reproduce when Activity is passed.
#29

W/System.err(18979): java.lang.ClassCastException: $Proxy0 cannot be cast to android.view.WindowManagerImpl
W/System.err(18979):    at android.view.Window.setWindowManager(Window.java:769)
W/System.err(18979):    at android.view.Window.setWindowManager(Window.java:750)
W/System.err(18979):    at android.app.Dialog.<init>(Dialog.java:194)
W/System.err(18979):    at android.app.AlertDialog.<init>(AlertDialog.java:201)
W/System.err(18979):    at android.app.AlertDialog$Builder.create(AlertDialog.java:1088)

Fixes are being made on the PlatformView side and will be dealt with on the native_webview side until the Flutter release is made.
flutter/engine#17511

black screen with android 10 and FLAG_SECURE

webView show as black screen with FLAG_SECURE in all device not support Chrome as Android system WebView Provider

in android 10 ,
and Huawei modern devices ,
can you supply any code to pass this issues

webview导致UI卡顿

在iOS上,打开网页关闭后,其他页面会卡顿。

日志如下:

Main Thread Checker: UI API called on a background thread: -[UIView removeFromSuperview]
PID: 3117, TID: 628092, Thread name: io.flutter.1.raster, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4 Flutter 0x0000000100b855d0 _ZN7flutter30FlutterPlatformViewsController11SubmitFrameEP15GrDirectContextNSt3__110shared_ptrINS_10IOSContextEEENS3_10unique_ptrINS_12SurfaceFrameENS3_14default_deleteIS8_EEEE + 4932
5 Flutter 0x0000000100b9ea60 _ZN7flutter10IOSSurface11SubmitFrameEP15GrDirectContextNSt3__110unique_ptrINS_12SurfaceFrameENS3_14default_deleteIS5_EEEE + 160
6 Flutter 0x0000000100e750c4 _ZN7flutter10Rasterizer13DrawToSurfaceERNS_9LayerTreeE + 604
7 Flutter 0x0000000100e75c00 _ZNSt3__110__function6__funcIZN7flutter10Rasterizer4DrawEN3fml6RefPtrINS2_8PipelineINS2_9LayerTreeEEEEEE3$1NS_9allocatorISA_EEFvNS_10unique_ptrIS7_NS_14default_deleteIS7_EEEEEEclEOSG + 116
8 Flutter 0x0000000100e753c4 _ZN7flutter10Rasterizer4DrawEN3fml6RefPtrINS_8PipelineINS_9LayerTreeEEEEE + 408
9 Flutter 0x0000000100e7bc10 _ZNSt3__110__function6__funcIZN7flutter5Shell14OnAnimatorDrawEN3fml6RefPtrINS2_8PipelineINS2_9LayerTreeEEEEENS4_9TimePointEE4$_30NS_9allocatorISB_EEFvvEEclEv + 100
10 Flutter 0x0000000100ba9948 _ZN3fml15MessageLoopImpl10FlushTasksENS_9FlushTypeE + 1472
11 Flutter 0x0000000100bac074 ZN3fml17MessageLoopDarwin11OnTimerFireEP16__CFRunLoopTimerPS0 + 32
12 CoreFoundation 0x0000000196b98134 E2D6A76B-6879-31A3-8168-DF49F94E17CD + 692532
13 CoreFoundation 0x0000000196b97e50 E2D6A76B-6879-31A3-8168-DF49F94E17CD + 691792
14 CoreFoundation 0x0000000196b9752c E2D6A76B-6879-31A3-8168-DF49F94E17CD + 689452
15 CoreFoundation 0x0000000196b9253c E2D6A76B-6879-31A3-8168-DF49F94E17CD + 668988
16 CoreFoundation 0x0000000196b91ba8 CFRunLoopRunSpecific + 424
17 Flutter 0x0000000100babf50 _ZN3fml17MessageLoopDarwin3RunEv + 88
18 Flutter 0x0000000100bab12c _ZNSt3__114__thread_proxyINS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEZN3fml6ThreadC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEE3$0EEEEEPvSJ + 196
19 libsystem_pthread.dylib 0x000000019692fd98 _pthread_start + 156
20 libsystem_pthread.dylib 0x000000019693374c thread_start + 8

play video canot fullscreen

E/InputMethodManager( 7734): b/117267690: Failed to get fallback IMM with expected displayId=14 actual IMM#displayId=0 view=com.hisaichi5518.native_webview.NativeWebView{33c78f VFEDHVC.. .F...... 0,0-1440,2432}
I/chromium( 7734): [INFO:CONSOLE(1)] "Uncaught (in promise) TypeError: fullscreen error", source: https://bobo.kkpp.space/DPlayer/DPlayer.min.js (1)

Intent error

Hi i get the error of the image
image

Https is replaced by intent and generates the following error.

Kotlin version

FAILURE: Build failed with an exception.

  • What went wrong:
    The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher.
    The following dependencies do not satisfy the required version:
    project ':native_webview' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50

pls update package

如何设置字体大小

在Android上显示,字体正常,在iPhone X上显示,字体太小,如何设置字体大小?

Can't paste text copied from other apps on Android 10

native_webview's "selection popup" may not be able to paste text copied from other apps on Android 10.
I think this is a bug in Android/Chrome(WebView)/Flutter(PlatformView), but it's not confirmed.

reproduction procedure

  1. open example app
  2. show search form
  3. input text
  4. copy text
  5. open another app
  6. copy text from another app
  7. paste text

See also

#48

Chrome's paste logic

https://source.chromium.org/chromium/chromium/src/+/master:content/public/android/java/src/org/chromium/content/browser/selection/SelectionPopupControllerImpl.java;l=488?q=SelectionpopupCOntrollerImpl&ss=chromium%2Fchromium%2Fsrc&originalUrl=https:%2F%2Fcs.chromium.org%2F

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.