flutter_secure_storage_linux_portal 0.1.0 copy "flutter_secure_storage_linux_portal: ^0.1.0" to clipboard
flutter_secure_storage_linux_portal: ^0.1.0 copied to clipboard

PlatformLinux

A Linux implementation of the flutter_secure_storage plugin using the XDG Desktop Portal Secret API (org.freedesktop.portal.Secret)

A Linux implementation of flutter_secure_storage using the XDG Desktop Secret Portal API (org.freedesktop.portal.Secret).

Usage #

Use this implementation when the application should use the Secret Portal API, such as when running in a sandboxed environment (e.g., Flatpak or Snap).

import 'package:flutter_secure_storage_linux_portal/flutter_secure_storage_linux_portal.dart';

FlutterSecureStorageLinuxPortal.registerWith();

Important

FlutterSecureStorageLinuxPortal.registerWith() must be explicitly called. Simply adding the package as a dependency is not sufficient.

Example #

The following example uses this implementation when running in Flatpak or Snap.

import 'dart:io';

import 'package:flutter_secure_storage_linux_portal/flutter_secure_storage_linux_portal.dart';

if (Platform.isLinux) {
  final environment = Platform.environment;

  final isFlatpak =
      environment.containsKey('FLATPAK_ID') ||
      environment['container'] == 'flatpak';
  final isSnap =
      environment.containsKey('SNAP') ||
      environment.containsKey('SNAP_NAME');
  final usePortal = isFlatpak || isSnap;

  if (usePortal) {
    FlutterSecureStorageLinuxPortal.registerWith();
  }
}

Tip

This is only an example of when to use the implementation. Applications may choose different conditions based on their environment or requirements.

Implementation Details #

The Secret Portal API provides a unique master secret for a sandboxed application.

Unlike the Secret Service API, it does not provide secure storage itself. Instead, applications can use the master secret to encrypt secrets and store them in a file, for example.

File Path #

The secrets are stored encrypted in a file:

$XDG_DATA_HOME/$APPLICATION_ID/secure_storage/secrets.json.

Cryptography #

For security details.

Important

Disclaimer: Support for this library is given as best effort.

This library has not been reviewed or vetted by security professionals.

Not interoperable with GNOME libsecret #

This implementation cannot retrieve secrets stored by flutter_secure_storage_linux or GNOME libsecret.

For more details, refer to this section.

Tip

flutter_secure_storage_linux_secret_service is interoperable and can retrieve secrets stored by flutter_secure_storage_linux.

Historical Background #

This package was originally developed to be part of the flutter_secure_storage repository in #1204. The PR was not merged, and it was published in a separate repository.

See also: #1203