A lightweight Python utility to simplify file handling in Flet applications — no need to use with open() anymore!
Flet File System is a small but powerful utility that makes working with files in Flet apps effortless. It handles reading, writing, editing, deleting, encrypting, and searching files automatically — all using pure Python and the cryptography library.
Supports both persistent and temporary storage and works seamlessly with text, JSON, images, audio, CSV, PDFs, and other binary files.
- 🔐 Built-in encryption using the
cryptographylibrary (Fernet). - 📁 Automatic directory handling for both persistent and temporary storage.
- 💾 Easy file operations — read, write, edit, delete, list, and search files with a single method call.
- 🧩 JSON support — automatically encodes and decodes JSON files.
- 🖼️ Binary file support — save and read images, audio, CSVs, PDFs, etc.
- 🧹 Storage management — clear entire directories safely.
- 🧠 Smart defaults — uses environment variables (
FLET_APP_STORAGE_DATA/FLET_APP_STORAGE_TEMP) or creates fallback paths automatically. - ⚙️ Fully compatible with Flet, works inside any Flet page or app.
python -m venv venvActivate it depending on your operating system:
-
Windows:
venv\Scripts\activate
-
macOS / Linux:
source venv/bin/activate
pip install flet[all] cryptography💡 Tip:
flet[all]installs all optional Flet extensions (such as audio, video, and WebView support), which are ideal for full-featured applications.
If you’re using a dependency manager such as Poetry or PDM, add the following lines under the [project] or [tool.poetry.dependencies] section:
dependencies = [
"flet==0.28.3",
"cryptography" # Required for file encryption
]📘 Note: The
FileSystemclass can also be used standalone in projects without Flet, as long asflet>=0.28.3is installed.
Check that everything was installed correctly:
python -m pip show flet cryptographyIf both packages are listed, you’re all set! 🎉
flet create <Your Project Name>Simply place the entire FileSystem folder inside your project’s main directory, for example:
your_flet_project/
├─ assets/
├─ src/
│ ├─ core/
│ │ └─ FileSystem/
│ │ ├─ __init__.py
│ │ ├─ FileSystem.py
| ├─ main.py
├─ .gitingore
├─ pyproject.toml
├─ README.md✅ Tip: Once copied, you can import it in your code like this:
from FileSystem import FileSystem
from flet import *
from FileSystem import FileSystem # your FileSystem class
def main(page: Page):
fs = FileSystem()
# Save an encrypted text file
fs.save_file(
file_name="Hello.txt",
file_content="Hello Flet!",
encrypt=True,
overwrite=True
)
# Save an image
with open("example.png", "rb") as f:
image_bytes = f.read()
fs.save_file("images/example_saved.png", image_bytes, overwrite=True)
# Read the encrypted text file
content = fs.read_file("Hello.txt")
# Read the image
saved_image = fs.read_file("images/example_saved.png")
with open("example_copy.png", "wb") as f:
f.write(saved_image)
page.add(
Column([
Text("✅ Text and image files saved and read successfully!"),
Text(f"Decrypted content: {content}")
])
)
app(target=main)| Method | Description |
|---|---|
save_file() |
Save a file (text, JSON, or binary) with optional encryption. |
read_file() |
Read and decrypt file contents automatically. |
edit_file() |
Modify an existing file easily. |
delete_file() |
Remove a file from storage. |
delete_folder() |
Delete an entire folder safely. |
list_files() |
List files from data and/or temp directories. |
search_files() |
Search one or multiple files by name, with optional recursive search. |
file_exists() |
Check if a file exists. |
clear_storage() |
Delete all files from a directory safely. |
| Platform | Status |
|---|---|
| Android | ✅ |
| Windows | ✅ |
| iOS | ❌ |
| macOS | ❌ |
| Linux | ❌ |
Encryption is handled automatically with the Fernet algorithm from the cryptography library.
Each FileSystem instance generates or reuses a .key file stored securely inside the temp directory.
| Variable | Description |
|---|---|
FLET_APP_STORAGE_DATA |
Path for persistent data storage. |
FLET_APP_STORAGE_TEMP |
Path for temporary storage and encryption keys. |
Fallback directories are created automatically if these variables are not set.
# Save JSON
fs.save_file("demo.json", {"name": "Flet", "type": "Framework"}, encrypt=False)
# List files
data_files, temp_files = fs.list_files(list_both_directories=True)
print(data_files, temp_files)Output:
['demo.json'] 'No Files Found'
data = fs.list_files(list_both_directories=True, show_details=True)
print(data)Output:
Data Storage (1): ['demo.json']
Temp Storage (0): 'No Files Found'
- Python 3.10+
- Flet
- cryptography
MIT License — free to use and modify.
Developed by MasterA5437S — making Flet development easier, one utility at a time 💙
Contributions are welcome and encouraged! 🎉
To contribute:
- Fork the repository.
- Create a new branch for your feature or fix.
- Commit your changes with clear, descriptive messages.
- Submit a Pull Request explaining what you’ve added or improved.
You can also open issues for bugs, suggestions, or improvements. All contributions — from fixing typos to adding new features — are greatly appreciated 💪
Together we can make Flet development faster, safer, and more enjoyable!