flutter_secure_storage_linux

3.0.3

Linux implementation of flutter_secure_storage

Download archive

Readme

flutter_secure_storage_linux

This is the platform-specific implementation of flutter_secure_storage for Linux.

Features

  • Secure storage using libsecret library.
  • Compatible with various Linux keyring services like GNOME Keyring and KDE KWallet.

Installation

Install libsecret — both the development package (to build) and the runtime package (to run). The runtime package (libsecret-1-0) is typically pre-installed on most Linux desktops.

Ubuntu / Debian-based (Linux Mint, Pop!_OS, …):

sudo apt install libsecret-1-0 libsecret-1-dev

Fedora / RHEL / CentOS:

sudo dnf install libsecret libsecret-devel

Arch-based (single package contains both):

sudo pacman -S libsecret

libsecret is included in Freedesktop runtime 25.08+ (also GNOME runtime 49, KDE runtime 6.10 and 5.15-25.08), so no extra manifest entry is needed:

runtime: org.freedesktop.Platform
runtime-version: '25.08' # must be 25.08 or newer

For older runtimes, use Flathub Shared Modules (shared-modules/libsecret/libsecret.json), though this is no longer recommended.

parts:
  your-app:
    plugin: flutter
    flutter-target: lib/main.dart
    build-packages:
      - libsecret-1-dev
    stage-packages:
      - libsecret-1-0

Note: libjsoncpp-dev is no longer required. The plugin uses a bundled header-only JSON library.

Configuration

Apart from libsecret, a running keyring service is required at runtime. This is typically already provided by the desktop environment:

  • GNOME / Ubuntu: gnome-keyring — usually active by default in a GNOME session.
  • KDE: kwallet — enabled via KDE Wallet Manager.
  • Other / lightweight: secret-service
  • Headless / CI: start gnome-keyring-daemon with an unlocked keyring:
    eval $(dbus-launch --sh-syntax)
    echo "" | gnome-keyring-daemon --unlock --daemonize --components=secrets
    

Known issues

Flutter installed via snap on Ubuntu 22.04+

Building with the Flutter snap may produce linker errors like:

undefined reference to `g_task_set_static_name'
undefined reference to `g_once_init_enter_pointer'

This is caused by a version mismatch between the GLib bundled in the Flutter snap and the system libsecret, which is compiled against a newer GLib. The plugin shared library links fine, but executables (including native test binaries) may fail to link.

Workaround: install Flutter via the official tar archive instead of snap, so the toolchain uses the system linker and libraries consistently.

Running the tests

Native tests (C++ / GoogleTest)

The native tests exercise the SecretStorage layer directly against a real keyring. Build the example app first to compile the test binary, then run via CTest:

# 1. Start a keyring daemon (skip if already running in a desktop session)
eval $(dbus-launch --sh-syntax)
echo "" | gnome-keyring-daemon --unlock --daemonize --components=secrets

# 2. Build (compiles the test binary alongside the app)
cd flutter_secure_storage/example
flutter build linux --debug

# 3. Run
cd build/linux/x64/debug/plugins/flutter_secure_storage_linux
ctest --output-on-failure

Integration tests

cd flutter_secure_storage/example
xvfb-run flutter test integration_test/linux_test.dart -d linux

Usage

Refer to the main flutter_secure_storage README for common usage instructions.

License

This project is licensed under the BSD 3 License. See the LICENSE file for details.

Changelog

Changelog

3.0.3 (2026-09-11)

Bug Fixes

  • linux: skip D-Bus keyring warmup when sandboxed (#1223) (1e625c9)

3.0.2 (2026-08-06)

Bug Fixes

  • handle missing default keyring on linux (b39c7c1)
  • linux: fail closed on orphaned keyring data (2e720ff)
  • linux: return structured libsecret error codes (4691b83)

3.0.1

  • Fixed deleteKeyring storing the string "null" instead of an empty JSON object {}.
  • Fixed non-UTF-8 error messages from libsecret causing a FormatException on the Dart side; messages are now sanitised before being sent through the method channel.
  • Fixed locked or unavailable keyring now surfacing as a catchable PlatformException with code KeyringLocked.
  • Fixed JSON parse errors and other C++ exceptions now surfacing as a PlatformException with code StorageError instead of sending malformed bytes through the channel.
  • Updated README with installation instructions for apt, dnf, pacman, Flatpak, and Snapcraft.

3.0.0

  • Fixed whitespace deprecation warning.
  • Reverted json.dump with indentations due to problems. If still needed, pin version to 2.x

2.0.1

Adds application ID to cmake file

2.0.0

  • This plugin requires a minimum dart sdk of 3.3.0 or higher and a minimum flutter version of 3.19.0.
  • Updated documentation

1.2.3

  • Adds application ID to cmake file

1.2.2

  • Fix json.dump with indentations

1.2.1

  • Fixed search with schemas fails in cold keyrings
  • Fixed erase called on null

1.2.0

  • Remove and replace libjsoncpp1 dependency
  • Update Dart SDK Constraint to support <4.0.0 instead of <3.0.0.

1.1.3

Fixed a memory management issue

1.1.2

Updated flutter_secure_storage_platform_interface to latest version.

1.1.1

Fixed an issue where no error was being reported if there was something wrong accessing the secret service.

1.1.0

Add containsKey function.

1.0.0

  • Initial Linux implementation
  • Removed unused Flutter test and effective_dart dependency

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add flutter_secure_storage_linux
pubspec.yaml
name: flutter_secure_storage_linux
description: Linux implementation of flutter_secure_storage
repository: https://github.com/mogol/flutter_secure_storage
version: 3.0.3
resolution: workspace

environment:
  sdk: '>=3.5.0 <4.0.0'
  flutter: '>=3.19.0'

dependencies:
  flutter:
    sdk: flutter
  flutter_secure_storage_platform_interface: ^2.0.1

flutter:
  plugin:
    implements: flutter_secure_storage
    platforms:
      linux:
        pluginClass: FlutterSecureStorageLinuxPlugin

Version history

VersionPublishedArchiveSHA-256
1.0.0On demandDownload97bd718b…f91cb7
1.1.0On demandDownloadc6e57a7c…0aba0a
1.1.1On demandDownload7b36defa…b1e1bb
1.1.2On demandDownload736436ad…8ea797
1.1.3On demandDownload0912ae29…efe2a3
1.2.0On demandDownload3d5032e3…ae6a9e
1.2.1On demandDownload4d91bfc2…f1464b
1.2.2On demandDownloadbf740461…e2d705
1.2.3On demandDownloadbe76c1d2…c8f688
2.0.0On demandDownloadb777e220…5105dc
2.0.1On demandDownload9b4b7312…42182c
3.0.0On demandDownload2b5c76dc…767cda
3.0.1On demandDownloada5f35dda…087bf5
3.0.2On demandDownload76fa9c84…168546
3.0.3Cached · Upstream SHA-256 matchedDownloadcaa75bd7…0458ea
4.0.0-beta.1On demandDownloadf908c47e…c354a5

Dependencies

flutter { "sdk": "flutter" }

flutter_secure_storage_platform_interface "^2.0.1"