Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

td3447/flet-secure-storage

Repository files navigation

flet-secure-storage

pypi license PyPI - Python Version

Requires Flet >=0.80.0.dev0

An encrypted storage option for Flet that stores data securely, based on the platform, it is designed to be similiar to the SharedPreferences (previously ClientStorage) class in Flet v1.

It utilizes the flutter_secure_storage Flutter package

Documentation

Link to documentation

Platform Support

Platform Supported
Windows
Android
Web
Linux
macOS 🚧
iOS 🚧

ℹ️ Note: Currently unable to verify on macOS or iOS.

Flet Compatibility

Version Supported
>= 0.80.0
< 0.28.3

Usage

Installation

To install the flet-secure-storage package and add it to your project dependencies:

  • Using uv:

    uv add flet-secure-storage
  • Using pip:

    pip install flet-secure-storage

    After this, you will have to manually add this package to your requirements.txt or pyproject.toml.

    [project]
    dependencies = [
        "flet-secure-storage",
        "flet>=0.80.0",
    ]

Basic Usage

Initialize

  • Add secure_storage to the page services.

    import flet as ft
    from flet_secure_storage import SecureStorage
    
    async def main(page: ft.Page):
        secure_storage = SecureStorage() # Create an instance of secure_storage
        page.services.append(secure_storage) # Add secure_storage to services
    
        # Code
    
    ft.run(main)

Initialize with Options

  • Add secure_storage to the page services.

    import flet as ft
    from flet_secure_storage import SecureStorage, AndroidOptions
    
    async def main(page: ft.Page):
        secure_storage = SecureStorage(
            prefix="com.example", # `.` is added automatically between prefix and key
            prefix_separator=".", # Default
            a_options=AndroidOptions(
                shared_preferences_name="my_project",
                preferences_key_prefix="com.project"
            )
            # Add other platform options
        ) # Create an instance of secure_storage
        page.services.append(secure_storage) # Add secure_storage to services
    
        # Code
    
    ft.run(main)

Functions

  • set - Set a value by key in storage

    await secure_storage.set("key", "value")
    
    return bool
  • get - Retrieve a value from storage by it's key

    value = await secure_storage.get("key")
    
    return value: str
  • contains_key - Check if a key exists in storage by it's key

    await secure_storage.contains_key("key"):
        
    return bool
  • remove - Removes the key, value pair from storage

    await secure_storage.remove("key")
    
    return bool
  • get_keys - Gets all keys that startwith the entered key. Returns all keys if blank.

    values = await secure_storage.get_keys("key": str = "")
    # No entry or an entry of '' will produce keys starting with the `prefix=` option.
    
    return values: list[str]
    
    # input key = "key"
    # return ['key1:value1', 'key2:value2']
  • clear - Clears all keys from storage.

    await secure_storage.remove("key")

Documentation

To get a more through explanation, check out the documentation.

About

A Flet extension based on flutter_secure_storage

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •