flutterdartflutter-desktopflutter-windowsflutter-linux

how to bundle flutter desktop assets into a single file for production build


after building the flutter project for desktop, flutter copies all asset files inside the assets directory into the build/flutter_assets/assets which are easily accessible and modifiable (which is not secure at all!), user can change the whole images easily and do some kind of modding the app with no experience required! or even in the worst situation with modifying the AssetManifest he could change the runtime dynamic libs with the malicious libs and get a hook from the app.

most modern frameworks/languages have the option to embed the resources inside a single file (that makes it harder to modify the files / repack the resource file) for example C#(WPF/Win32) embeds the resources in the resource Resource section or even Electron (Javascript) embed the whole resources into a file (it's easy but better than nothing)

I didn't find any similar behavior in Flutter Desktop (Windows/Mac/Linux) is there any alternative for flutter?


Solution

  • For now [12/12/22] it seems flutter desktop won't use resources to bundle the resources into a single file.
    So I've created two separate libraries to achieve this

    1. https://github.com/kooroshh/bundler that compresses the whole given assets into a single file and encrypts it with AES-128
    2. https://github.com/kooroshh/flutter_bundler that reads the bundle file from and decrypts it into the memory that can be used with Image.memory or Direct file access using Virtual Files.

    I hope an official solution gets implemented in the flutter framework.