“我的”页面,点击返回报错

来源:16-8 旅拍页面交互与我的页面实现

leslie1996

2019-11-24

“我的”页面中,点击webview中h5左上角自带的返回按钮,页面会跳转到携程的首页,并且log中抛出异常

D/EGL_emulation(14779): eglMakeCurrent: 0xafe18100: ver 3 0 (tinfo 0xb18dc970)
E/MethodChannel#flutter_webview_plugin(14779): Failed to handle method call
E/MethodChannel#flutter_webview_plugin(14779): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child’s parent first.
E/MethodChannel#flutter_webview_plugin(14779): at android.view.ViewGroup.addViewInner(ViewGroup.java:5106)
E/MethodChannel#flutter_webview_plugin(14779): at android.view.ViewGroup.addView(ViewGroup.java:4935)
E/MethodChannel#flutter_webview_plugin(14779): at android.view.ViewGroup.addView(ViewGroup.java:4907)
E/MethodChannel#flutter_webview_plugin(14779): at com.android.internal.policy.PhoneWindow.addContentView(PhoneWindow.java:488)
E/MethodChannel#flutter_webview_plugin(14779): at android.app.Activity.addContentView(Activity.java:3372)
E/MethodChannel#flutter_webview_plugin(14779): at com.flutter_webview_plugin.FlutterWebviewPlugin.openUrl(FlutterWebviewPlugin.java:141)
E/MethodChannel#flutter_webview_plugin(14779): at com.flutter_webview_plugin.FlutterWebviewPlugin.onMethodCall(FlutterWebviewPlugin.java:53)
E/MethodChannel#flutter_webview_plugin(14779): at io.flutter.plugin.common.MethodChannelKaTeX parse error: Expected 'EOF', got '#' at position 76: …E/MethodChannel#̲flutter_webview…MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#flutter_webview_plugin(14779): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/flutter (14779): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, The specified child already has a parent. You must call removeView() on the child’s parent first., null)
E/flutter (14779): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (14779): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
E/flutter (14779):
E/flutter (14779): #2 FlutterWebviewPlugin.launch (package:flutter_webview_plugin/src/base.dart:220:20)
E/flutter (14779):
E/flutter (14779): #3 _WebviewState.initState. (package:flutter_trip/widget/webview.dart:51:32)
E/flutter (14779): #4 _rootRunUnary (dart:async/zone.dart:1132:38)
E/flutter (14779): #5 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (14779): #6 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter (14779): #7 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
E/flutter (14779): #8 _DelayedData.perform (dart:async/stream_impl.dart:591:14)
E/flutter (14779): #9 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:707:11)
E/flutter (14779): #10 _PendingEvents.schedule. (dart:async/stream_impl.dart:667:7)
E/flutter (14779): #11 _rootRun (dart:async/zone.dart:1120:38)
E/flutter (14779): #12 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (14779): #13 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (14779): #14 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
E/flutter (14779): #15 _rootRun (dart:async/zone.dart:1124:13)
E/flutter (14779): #16 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (14779): #17 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (14779): #18 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
E/flutter (14779): #19 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (14779): #20 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

写回答

3回答

SDKx

2020-03-02

主要是这句:The specified child already has a parent. You must call removeView() on the child’s parent first.


我这里也报错,不知道咋处理,网上也搜不到

0
0

leslie1996

提问者

2019-11-25

//img.mukewang.com/szimg/5ddbdfb50931513e19161015.jpg


@CrazyCodeBoy 老师这是本地运行老师源码异常的截图

0
0

CrazyCodeBoy

2019-11-25

应该是代码实现的问题,对照下这块的课程源码检查下你的代码看是不是有出入的地方:
https://git.imooc.com/coding-321/flutter_trip/src/master/lib/pages/my_page.dart
https://git.imooc.com/coding-321/flutter_trip/src/master/lib/widget/webview.dart

0
2
儒雅的中国宅男
老师不解决一下吗?
2020-07-26
共2条回复

Flutter从入门到进阶 实战携程网App 一网打尽核心技术

解锁Flutter开发新姿势,,系统掌握Flutter开发核心技术。

4788 学习 · 3270 问题

查看课程