简体   繁体   English

webView 在颤振中不起作用 [ERROR:flutter/lib/ui/ui_dart_state.cc(157)]

[英]webView don't work in flutter [ERROR:flutter/lib/ui/ui_dart_state.cc(157)]

I add in pubspec.yaml webview_flutter: ^0.3.19+8 i use Flutter version 1.12.13+hotfix.8我添加了 pubspec.yaml webview_flutter: ^0.3.19+8我使用 Flutter 版本 1.12.13+hotfix.8

and it's my code这是我的代码

import 'package:webview_flutter/webview_flutter.dart';

void main() => runApp(MaterialApp(
  home: app(),
));

class app extends StatefulWidget {
  @override
  _appState createState() => _appState();
}

class _appState extends State<app> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('App mobile'),
      ),
      body: Container(
        constraints: BoxConstraints(maxHeight: 500),
        child: WebView(
          initialUrl: "https://google.com",
        ),
      )
    );
  }
}

but after Run and click in white emulator screen, in tab Run i have this...但是在运行并单击white模拟器屏幕后,在运行选项卡中,我有这个...

E/flutter ( 9570): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Sending touch to an unknown view with id: 1
E/flutter ( 9570):  at io.flutter.plugin.platform.PlatformViewsController$1.onTouch(PlatformViewsController.java:206)
E/flutter ( 9570):  at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.touch(PlatformViewsChannel.java:168)
...

I will appreciate any help...我将不胜感激任何帮助...

I used this and works fine with me, I think you missed to use the controller我用过这个并且对我很好,我想你错过了使用controller

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

class WebViewScreen extends StatefulWidget {
  final String title;
  final String selectedUrl;

  WebViewScreen({@required this.title, @required this.selectedUrl});

  @override
  _WebViewScreenState createState() => _WebViewScreenState();
}

class _WebViewScreenState extends State<WebViewScreen> {
  Completer<WebViewController> _controller = Completer<WebViewController>();
  bool isLoading = true;

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: WebView(
        initialUrl: widget.selectedUrl,
        onWebViewCreated: (WebViewController webViewController) {
          _controller.complete(webViewController);
        },
      ),
    );
  }
}

如果您在发布模式下遇到此错误,请检查您的清单文件中的“android.permission.INTERNET”权限。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 E/flutter (8084): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] 未处理的异常:SocketException:操作系统错误:连接被拒绝 - E/flutter ( 8084): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: SocketException: OS Error: Connection refused 错误:flutter/lib/ui/ui_dart_state.cc(209) - ERROR:flutter/lib/ui/ui_dart_state.cc(209) 错误:flutter/lib/ui/ui_dart_state.cc(148) 未处理的异常 - ERROR:flutter/lib/ui/ui_dart_state.cc(148) Unhandled Exception Flutter [错误:flutter/lib/ui/ui_dart_state.cc(177)] 未处理的异常:类型“int”不是类型转换中类型“String”的子类型 - Flutter [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: type 'int' is not a subtype of type 'String' in type cast 错误:flutter/lib/ui/ui_dart_state.cc(209)]未处理的异常:类型'String'不是类型转换中类型'int'的子类型 - ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'String' is not a subtype of type 'int' in type cast 发布序列化 Json 正文 - [VERBOSE-2:ui_dart_state.cc(177)] 未处理的异常:错误 - - Post serialised Json body - [VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: Error- 运行 flutter 应用程序时如何解决“dart:ui”错误? - How to solved 'dart:ui' error when going to run flutter app? Flutter riverpod 提供程序未在 UI 中更新 state - Flutter riverpod provider not updating state in UI 我的“If”语句在 dart/flutter 中不起作用 - My "If" statement doesn't work in dart/flutter 飞镖:捕获Flutter Webview的图像 - Dart : capture an image of a Flutter webview
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM