我正在尝试使用url_launcher
,以便可以通过URL查看文章,但得到MissingPluginException
。有人能帮我吗?这是我的一些代码:
Widget _builder(Article article){
return new Padding(
padding: const EdgeInsets.all(8.0),
child: ListTile(
title: new Text(article.text,style: TextStyle(
fontSize: 24.0,
),
),
subtitle: new Text(article.by),
onTap: () async {
final fakeUrl='www.${article.domain}';
if (await canLaunch(fakeUrl)){
launch(fakeUrl);
} else print("could not be opened");
),
);
}
这是我的错误:
E/flutter (18223): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method canLaunch on channel plugins.flutter.io/url_launcher)
E/flutter (18223): #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)
E/flutter (18223): <asynchronous suspension>
E/flutter (18223): #1 MethodChannelUrlLauncher.canLaunch (package:url_launcher_platform_interface/method_channel_url_launcher.dart:18:21)
E/flutter (18223): #2 canLaunch (package:url_launcher/url_launcher.dart:108:45)
E/flutter (18223): #3 _MyHomePageState._builder.<anonymous closure> (package:flutter_apps/main.dart:62:23)
E/flutter (18223): #4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
E/flutter (18223): #5 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36)
E/flutter (18223): #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (18223): #7 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
E/flutter (18223): #8 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
E/flutter (18223): #9 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236:7)
E/flutter (18223): #10 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (18223): #11 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
E/flutter (18223): #12 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (18223): #13 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (18223): #14 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (18223): #15 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (18223): #16 _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter (18223): #17 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (18223): #18 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter (18223): #19 _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter (18223): #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
答案 0 :(得分:0)
您应该通过Flutter clean
来清理项目。
如果仍然存在,则应将{@ 1}升级为flutter仓库,此问题将得到肯定解决。您可以跟踪this issue here.