如何将松弛集成到Flutter应用程序中以共享文本和图像?我在用 此软件包以启动应用https://pub.dev/packages/flutter_appavailability。为简单起见,我可以说设备上已安装了Slack,所以我现在正在测试是否可以打开Slack。我完全知道我可以检查是否使用相同的插件安装了该应用程序。
AppAvailability.launchApp("slack://open").then((_) {
print("App slack launched");
}).catchError((err) {
Scaffold.of(context).showSnackBar(SnackBar(
content: Text(" App not found!")
));
print(err);
});
https://api.slack.com/reference/deep-linking#open_slack#client 这是Slack Open API文档。
Stacktrace:
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): Failed to handle method call
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at com.pichillilorenzo.flutter_appavailability.AppAvailability.getAppPackageInfo(AppAvailability.java:93)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at com.pichillilorenzo.flutter_appavailability.AppAvailability.launchApp(AppAvailability.java:131)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at com.pichillilorenzo.flutter_appavailability.AppAvailability.onMethodCall(AppAvailability.java:57)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): Failed to handle method call
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at com.pichillilorenzo.flutter_appavailability.AppAvailability.getAppPackageInfo(AppAvailability.java:93)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at com.pichillilorenzo.flutter_appavailability.AppAvailability.checkAvailability(AppAvailability.java:65)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at com.pichillilorenzo.flutter_appavailability.AppAvailability.onMethodCall(AppAvailability.java:46)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 2076): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/flutter ( 2076): PlatformException(error, Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference, null)
E/flutter ( 2076): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference, null)
E/flutter ( 2076): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter ( 2076): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter ( 2076): <asynchronous suspension>
E/flutter ( 2076): #2 AppAvailability.checkAvailability (package:flutter_appavailability/flutter_appavailability.dart:29:50)
E/flutter ( 2076): #3 LaunchSlackWidget.getApps (package:remotebingo/screen/LaunchSlackWidget.dart:21:35)
E/flutter ( 2076): <asynchronous suspension>
E/flutter ( 2076): #4 _TitleWidget.build.<anonymous closure> (package:remotebingo/screen/EndGameSuccess.dart:104:28)
E/flutter ( 2076): #5 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
E/flutter ( 2076): #6 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36)
E/flutter ( 2076): #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter ( 2076): #8 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
E/flutter ( 2076): #9 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
E/flutter ( 2076): #10 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:199:7)
E/flutter ( 2076): #11 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:467:9)
E/flutter ( 2076): #12 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter ( 2076): #13 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:117:9)
E/flutter ( 2076): #14 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
E/flutter ( 2076): #15 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:115:18)
E/flutter ( 2076): #16 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:7)
E/flutter ( 2076): #17 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter ( 2076): #18 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter ( 2076): #19 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter ( 2076): #20 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter ( 2076): #21 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter ( 2076): #22 _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter ( 2076): #23 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter ( 2076): #24 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter ( 2076): #25 _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter ( 2076): #26 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
E/flutter ( 2076):
有人可以帮我了解我在这里做错了吗