使用URL_Launcher软件包在Flutter上出错

时间:2020-08-29 16:27:35

标签: android ios flutter asynchronous dart

从昨天开始,当我在url_launcher包中使用GestureDetector时,出现此错误:

E/flutter (17573): #0      _musicAreaState._launchURL (package:GiramosApp/ui/views/home_screen/widgets/music_area.dart:37:7)
E/flutter (17573): <asynchronous suspension>
E/flutter (17573): #1      _musicAreaState.build.<anonymous closure> (package:GiramosApp/ui/views/home_screen/widgets/music_area.dart:55:13)
E/flutter (17573): #2      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
E/flutter (17573): #3      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:598:11)
E/flutter (17573): #4      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:287:5)
E/flutter (17573): #5      BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:259:7)
E/flutter (17573): #6      GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157:27)
E/flutter (17573): #7      GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:224:20)
E/flutter (17573): #8      GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:200:22)
E/flutter (17573): #9      RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:263:11)
E/flutter (17573): #10     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:157:7)
E/flutter (17573): #11     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:103:7)
E/flutter (17573): #12     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:87:7)
E/flutter (17573): #13     _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (17573): #14     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (17573): #15     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (17573): #16     _invoke1 (dart:ui/hooks.dart:265:10)
E/flutter (17573): #17     _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)
E/flutter (17573): ```

Any thoughts?

2 个答案:

答案 0 :(得分:0)

使用here给出的步骤正确安装软件包。您应该在pubspec.yaml文件中添加url_launcher的依赖项。如果这样做,

要解决此问题,您应该使用flutter clean清理项目,然后使用flutter upgrade升级Flutter。这样可以肯定解决问题。如果没有,则创建一个新项目,然后将代码粘贴到其中。

答案 1 :(得分:0)

我发现了错误,我不知道为什么,但是删除异步功能可以正常工作。因此,结果是:

launchUrl(url) {
   launch(url);
 }

在iOS上,它具有异步风格,但在Android上不起作用。