MissingPluginException(未找到方法 DocumentReference 的实现)从 flutter isolate 将数据发送到 firestore
MissingPluginException(No implementation found for method DocumentReference) on Send data to firestore from flutter isolate
我正在尝试在 Flutter 中制作一个后台位置跟踪应用程序。所以我为 运行 后台服务创建了一个隔离。如果我将位置数据从 isolate 存储在本地文件系统中,它会很好地工作。但是当我连接 Firebase 以从 isolate 发送数据时,出现以下错误:
E/flutter (10142): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method DocumentReference#setData on channel plugins.flutter.io/cloud_firestore)
E/flutter (10142): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
E/flutter (10142): <asynchronous suspension>
E/flutter (10142): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
E/flutter (10142): #2 MethodChannelDocumentReference.setData (package:cloud_firestore_platform_interface/src/method_channel/method_channel_document_reference.dart:28:43)
E/flutter (10142): #3 DocumentReference.setData (package:cloud_firestore/src/document_reference.dart:48:22)
E/flutter (10142): #4 LocationServiceRepository.callback (package:alertcat/backLocation/location_service_repository.dart:61:15)
E/flutter (10142): #5 LocationCallbackHandler.callback (package:alertcat/backLocation/location_callback_handler.dart:23:40)
E/flutter (10142): #6 callbackDispatcher.<anonymous closure> (package:background_locator/callback_dispatcher.dart:22:15)
E/flutter (10142): #7 MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:409:55)
E/flutter (10142): #8 MethodChannel.setMethodCallHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:377:54)
E/flutter (10142): #9 _DefaultBinaryMessenger.handlePlatformMessage (package:flutter/src/services/binding.dart:199:33)
E/flutter (10142): #10 _invoke3.<anonymous closure> (dart:ui/hooks.dart:290:15)
E/flutter (10142): #11 _rootRun (dart:async/zone.dart:1184:13)
E/flutter (10142): #12 _CustomZone.run (dart:async/zone.dart:1077:19)
E/flutter (10142): #13 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
E/flutter (10142): #14 _invoke3 (dart:ui/hooks.dart:289:10)
E/flutter (10142): #15 _dispatchPlatformMessage (dart:ui/hooks.dart:164:5)
但 Firebase 在隔离外部正常运行。我该怎么做才能解决这个问题?
确保您使用的是最新的 cloud_firestore
版本。然后执行:
flutter clean
flutter packages get
从 emulator/phone 中删除应用程序,关闭 ide 并重新打开它。
主要问题是内部依赖,还有另一个第三方包与 firestore 包有某种冲突,
为了解决这个问题,我为另一个包写了本地代码,现在可以正常工作了
我正在尝试在 Flutter 中制作一个后台位置跟踪应用程序。所以我为 运行 后台服务创建了一个隔离。如果我将位置数据从 isolate 存储在本地文件系统中,它会很好地工作。但是当我连接 Firebase 以从 isolate 发送数据时,出现以下错误:
E/flutter (10142): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method DocumentReference#setData on channel plugins.flutter.io/cloud_firestore)
E/flutter (10142): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
E/flutter (10142): <asynchronous suspension>
E/flutter (10142): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
E/flutter (10142): #2 MethodChannelDocumentReference.setData (package:cloud_firestore_platform_interface/src/method_channel/method_channel_document_reference.dart:28:43)
E/flutter (10142): #3 DocumentReference.setData (package:cloud_firestore/src/document_reference.dart:48:22)
E/flutter (10142): #4 LocationServiceRepository.callback (package:alertcat/backLocation/location_service_repository.dart:61:15)
E/flutter (10142): #5 LocationCallbackHandler.callback (package:alertcat/backLocation/location_callback_handler.dart:23:40)
E/flutter (10142): #6 callbackDispatcher.<anonymous closure> (package:background_locator/callback_dispatcher.dart:22:15)
E/flutter (10142): #7 MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:409:55)
E/flutter (10142): #8 MethodChannel.setMethodCallHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:377:54)
E/flutter (10142): #9 _DefaultBinaryMessenger.handlePlatformMessage (package:flutter/src/services/binding.dart:199:33)
E/flutter (10142): #10 _invoke3.<anonymous closure> (dart:ui/hooks.dart:290:15)
E/flutter (10142): #11 _rootRun (dart:async/zone.dart:1184:13)
E/flutter (10142): #12 _CustomZone.run (dart:async/zone.dart:1077:19)
E/flutter (10142): #13 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
E/flutter (10142): #14 _invoke3 (dart:ui/hooks.dart:289:10)
E/flutter (10142): #15 _dispatchPlatformMessage (dart:ui/hooks.dart:164:5)
但 Firebase 在隔离外部正常运行。我该怎么做才能解决这个问题?
确保您使用的是最新的 cloud_firestore
版本。然后执行:
flutter clean
flutter packages get
从 emulator/phone 中删除应用程序,关闭 ide 并重新打开它。
主要问题是内部依赖,还有另一个第三方包与 firestore 包有某种冲突,
为了解决这个问题,我为另一个包写了本地代码,现在可以正常工作了