Skip to content

PlatformException(channel-error) when using shared_preferences on Flutter Desktop #438

@Vaache

Description

@Vaache

I’m getting the following error when trying to use the shared_preferences package in a Flutter desktop app (with multiple windows / secondary engine):

PlatformException(channel-error, Unable to establish connection on channel: "dev.flutter.pigeon.shared_preferences_foundation.LegacyUserDefaultsApi.getAll"., null, null)

It looks like the plugin cannot establish a connection to the method channel.
From what I understand, shared_preferences relies on a platform channel that may not be registered when using multiple Flutter engines or secondary windows.


Questions

  1. What exactly does this error mean?
  2. Is shared_preferences limited to only the main Flutter engine?
  3. How can I make it work in a secondary window / secondary FlutterEngine?
  4. Is there a workaround (e.g., registering the plugin manually, or using another approach for storing preferences in additional windows)?

Environment

  • Flutter:
    Flutter 3.35.4

Framework • revision d693b4b9db (9 days ago) • 2025-09-16 14:27:41 +0000
Engine • hash feee8ee8fb8b975dd9990f86d3bda11e6e75faf3 (revision c298091351) (10 days ago) • 2025-09-15 14:04:24.000Z
Tools • Dart 3.9.2 • DevTools 2.48.0

  • OS: [macOS/Linux/Windows]
  • Package: shared_preferences [version]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions