Skip to content

fix(flet-lottie): local asset files not loading on Windows desktop#6426

Open
ndonkoHenri wants to merge 8 commits intorelease/v0.85.0from
fix-lottie
Open

fix(flet-lottie): local asset files not loading on Windows desktop#6426
ndonkoHenri wants to merge 8 commits intorelease/v0.85.0from
fix-lottie

Conversation

@ndonkoHenri
Copy link
Copy Markdown
Contributor

@ndonkoHenri ndonkoHenri commented Apr 17, 2026

When src="sample.json" is passed, Flet's getAssetSource() resolves it to an absolute filesystem path (e.g. C:\Users\...\assets\sample.json). flet-lottie was passing that path to Lottie.asset(...), which is the Flutter asset-bundle API — it looks up keys registered in pubspec.yaml at build time, not arbitrary filesystem paths. On Windows this surfaces as Unable to load asset: "C:\...".

As fix, we now route filesystem paths through Lottie.file(io.File(path)) instead, for better local file handling.

Resolves #6386

Test Code

import flet as ft
import flet_lottie as ftl


def main(page: ft.Page):
    page.add(
        ft.SafeArea(
            content=ft.Column(
                controls=[
                    ftl.Lottie(
                        src="https://raw.githubusercontent.com/xvrh/lottie-flutter/master/example/assets/Mobilo/A.json",
                        reverse=False,
                        animate=True,
                        error_content=ft.Placeholder(ft.Text("Error loading Lottie")),
                        on_error=lambda e: print(f"Error loading Lottie: {e.data}"),
                    ),
                    ftl.Lottie(
                        src="sample.json",
                        reverse=False,
                        animate=True,
                        enable_merge_paths=True,
                        enable_layers_opacity=True,
                        error_content=ft.Placeholder(ft.Text("Error loading Lottie")),
                        on_error=lambda e: print(f"Error loading Lottie: {e.data}"),
                    ),
                ],
            ),
        )
    )


if __name__ == "__main__":
    ft.run(main)

Summary by Sourcery

Route local Lottie JSON asset paths through a new file-based loader to fix desktop file loading issues and keep web builds compiling.

Bug Fixes:

  • Resolve failures to load local Lottie JSON assets on Windows desktop (and intermittently on other desktop platforms) when referenced via src in the app assets directory.

Enhancements:

  • Introduce a platform-aware fileLottie wrapper that uses Lottie.file for filesystem paths on IO platforms while providing a stub on web.
  • Bump the lottie Flutter dependency from 3.3.2 to 3.3.3 in the flet-lottie package.

Documentation:

  • Add a CHANGELOG entry for version 0.85.0 documenting the desktop local asset loading fix.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes flet-lottie failing to load local Lottie JSON files on Windows desktop by switching local (filesystem) sources to use Lottie.file(...) instead of Flutter’s asset-bundle API (Lottie.asset(...)), which expects build-time registered assets.

Changes:

  • Route AssetSource.isFile Lottie sources through a new fileLottie() helper that calls Lottie.file(...) on IO platforms.
  • Add conditional export (file_lottie.dart) with an IO implementation and a web stub to keep web builds compiling.
  • Bump the Flutter lottie dependency and add a changelog entry describing the fix.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sdk/python/packages/flet-lottie/src/flutter/flet_lottie/pubspec.yaml Updates lottie dependency version used by the Flutter side of flet-lottie.
sdk/python/packages/flet-lottie/src/flutter/flet_lottie/lib/src/lottie.dart Switches local file loading from Lottie.asset to the new fileLottie() wrapper.
sdk/python/packages/flet-lottie/src/flutter/flet_lottie/lib/src/file_lottie.dart Adds conditional export to select IO vs web implementation.
sdk/python/packages/flet-lottie/src/flutter/flet_lottie/lib/src/file_lottie_io.dart Implements fileLottie() via Lottie.file(io.File(path)) for desktop/mobile.
sdk/python/packages/flet-lottie/src/flutter/flet_lottie/lib/src/file_lottie_web.dart Provides a web stub (throws) to keep the package compiling on web.
sdk/python/packages/flet-lottie/CHANGELOG.md Documents the fix under a new release entry.
client/pubspec.lock Updates resolved dependency versions for the Flutter client workspace.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 17, 2026

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6ead027
Status:🚫  Build failed.

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 17, 2026

Deploying flet-examples with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6ead027
Status: ✅  Deploy successful!
Preview URL: https://e7138d5f.flet-examples.pages.dev
Branch Preview URL: https://fix-lottie.flet-examples.pages.dev

View logs

@ndonkoHenri ndonkoHenri linked an issue Apr 18, 2026 that may be closed by this pull request
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Example of locally hosted Lottie file doesnt work

2 participants