将数据/消息从颤动的应用程序传递到其他应用程序

问题描述 投票:0回答:1

我正在尝试将数据从我的扑腾应用程序传递到其他应用程序。目的是将我的应用程序的下载链接发送到另一个应用程序(比如watsapp,facebook,twitter等)。我正在使用flutter插件共享0.6.0 + 1。我按照说明添加了包裹。但是当我运行该程序时,显示以下错误:

[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method share on channel plugins.flutter.io/share) E/flutter ( 8153): #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:300:7) E/flutter ( 8153): <asynchronous suspension> E/flutter ( 8153): #1 Share.share (package:share/share.dart:44:20) E/flutter ( 8153): #2 _MyHomePageState.build.<anonymous closure> (package:unit_converter/main.dart:409:34) E/flutter ( 8153): #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:513:14) E/flutter ( 8153): #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:568:30) E/flutter ( 8153): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:120:24) E/flutter ( 8153): #6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9) E/flutter ( 8153): #7 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7) E/flutter ( 8153): #8 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27) E/flutter ( 8153): #9 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:20) E/flutter ( 8153): #10 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:192:22) E/flutter ( 8153): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:149:7) E/flutter ( 8153): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7) E/flutter ( 8153): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7) E/flutter ( 8153): #14 _rootRunUnary (dart:async/zone.dart:1136:13) E/flutter ( 8153): #15 _CustomZone.runUnary (dart:async/zone.dart:1029:19) E/flutter ( 8153): #16 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7) E/flutter ( 8153): #17 _invoke1 (dart:ui/hooks.dart:223:10) E/flutter ( 8153): #18 _dispatchPointerDataPacket (dart:ui/hooks.dart:144:5)

以下是我的pubspec.yaml文件的内容:

    dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  dart2_constant: ^1.0.2+dart2
  math_expressions: ^1.0.0
  shared_preferences: ^0.4.3
  #loader_search_bar: ^1.0.3+1
  material_search: ^0.2.8
  path_provider: '>=0.3.0'
  sqflite: any
  flutter_colorpicker: ^0.2.1
  intl: ^0.15.7
  auto_size_text: ^0.3.0
  cloud_firestore: ^0.9.0
  animated_text_kit: ^1.3.0
  share: ^0.6.0+1

以下是我的实施:

Share.share('Hi, take a time to click and download this app: market://search?q=pname:com.myappbase.appname');

请任何人都可以指出我做错了什么。我似乎已经尝试了所有的东西,但是同样的错误已经出现了。或者有更优雅的方式可以做到这一点吗?谢谢

dart flutter
1个回答
1
投票

您必须终止应用程序并从头开始重新运行,因为share依赖项需要调用platform channel方法。应用程序必须从头开始终止并重新运行。

© www.soinside.com 2019 - 2024. All rights reserved.