我正在尝试从 Node.js API 向 Flutter 应用程序发送通知。\n首先,我想让我的应用程序能够接收来自 Firebase 的通知。
\n但是,当我初始化App时,我遇到了一个问题:
\n\n\nPlatformException (PlatformException(null-error, 主机平台\n非空返回值返回空值。, null, null))
\n
在控制台中:
\nE/flutter (25357): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(null-error, Host platform returned null value for non-null return value., null, null)\nE/flutter (25357): #0 FirebaseCoreHostApi.optionsFromResource (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:250)\npackage:firebase_core_platform_interface/\xe2\x80\xa6/pigeon/messages.pigeon.dart:1\nE/flutter (25357): <asynchronous suspension>\nE/flutter (25357): #1 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:89)\npackage:firebase_core_platform_interface/\xe2\x80\xa6/method_channel/method_channel_firebase.dart:1\nE/flutter (25357): <asynchronous suspension>\nE/flutter (25357): #2 Firebase.initializeApp (package:firebase_core/src/firebase.dart:40)\npackage:firebase_core/src/firebase.dart:1\nE/flutter (25357): <asynchronous suspension>\nE/flutter (25357): #3 main (package:notifappfcm/main.dart:13)\npackage:notifappfcm/main.dart:1\nRun Code Online (Sandbox Code Playgroud)\n我一直在寻找解决这个问题的办法,但实在找不到。
\n这是我的应用程序代码:
\n主程序.dart
\nimport \'package:firebase_messaging/firebase_messaging.dart\';\nimport \'package:flutter/material.dart\';\nimport \'package:firebase_core/firebase_core.dart\';\nimport \'mainscreen.dart\';\n\nFuture<void> _firebadeMessagingBackgroundHandler(RemoteMessage message) async {\n await …Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序中实现 Stripe。
\n为此,我有以下模式:
\n用户点击产品,它会链接到后端,后端生成 PaymentIntent 并将其发送到前端。当我的前端收到 Intent 时,他会要求卡、号码和数据来请求 Stripe 的 API。
\n但
\n创建 Front 后,我遇到了问题,无法编译我的代码......
\n所以,这就是我的申请的制作方式:
\n在 main.dart 中:
\nvoid main() async {\n WidgetsFlutterBinding.ensureInitialized();\n\n /// Initialize Stripe\n Stripe.publishableKey = "**********************************************";\n\n.....\n.....\n.....\n}\nRun Code Online (Sandbox Code Playgroud)\n在product.dart(产品页面)中:
\n\nimport 'package:flutter/material.dart';\nimport 'package:flutter_stripe/flutter_stripe.dart';\n\nimport '../../services/api.dart';\n\nclass ProductsPage extends StatefulWidget {\n const ProductsPage({Key? key}) : super(key: key);\n\n @override\n State<ProductsPage> createState() => _ProductsPageState();\n}\n\nclass _ProductsPageState extends State<ProductsPage> {\n String? intentPayment;\n final productsList = [\n {\n "name": "Abonnement 30 jours",\n "description": "Abonnement test 30 jours",\n "price": …Run Code Online (Sandbox Code Playgroud)