Flutter 应用登录异常。平台异常错误

Flutter app login Exception has occurred. PlatformException error

我有一个 flutter 应用程序,但每次登录时都会出现异常错误,我必须按 f5 以确保该过程已完成。这是错误

Exception has occurred.
PlatformException (PlatformException(error, Task io.flutter.plugins.sharedpreferences.MethodCallHandlerImpl@f33e5c6 rejected from java.util.concurrent.ThreadPoolExecutor@63f5987[Running, pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 0], null, java.util.concurrent.RejectedExecutionException: Task io.flutter.plugins.sharedpreferences.MethodCallHandlerImpl@f33e5c6 rejected from java.util.concurrent.ThreadPoolExecutor@63f5987[Running, pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 0]
    at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2085)
    at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:848)
    at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1394)
    at io.flutter.plugins.sharedpreferences.MethodCallHandlerImpl.commitAsync(MethodCallHandlerImpl.java:137)
    at io.flutter.plugins.sharedpreferences.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:96)
    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
    at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
    at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:326)
    at android.os.Looper.loop(Looper.java:165)
    at android.app.ActivityThread.main(ActivityThread.java:6820)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:922)
))

你应该降级到

shared_preferences: 2.0.1

没有

shared_preferences: ^2.0.1

如果您使用的是测试版或稳定版

shared_preferences: ^0.5.12+4

似乎该错误已在 shared_preferences 2.0.4 中修复(至少对我而言有效)