Skip to content

[Web] file_loader.dart:91 throws "Unexpected null value" in non-WASM builds #615

@Knupper

Description

@Knupper

Description

When building a Flutter web app without the --wasm flag (i.e., compiling to JavaScript via dart2js/DDC), loading a .riv file throws an Unexpected null value (TypeErrorImpl) at package:rive/src/file_loader.dart:91. The same .riv file loads and renders correctly when the app is built with --wasm.

This suggests a null-safety or platform-check issue in the JS (non-WASM) web runtime path — specifically in rive_native's web implementation (rive_web.dart:99) which propagates a null value up to file_loader.dart:91.

Rive animations should work regardless of whether the web build uses WASM or JavaScript compilation.

Steps To Reproduce

  1. Create a Flutter web app that uses a Rive animation via RiveAnimation.asset(...) or by loading a .riv file manually.
  2. Build/run with WASM: flutter build web --wasm — animation loads and works correctly.
  3. Build/run without WASM: flutter build web (or flutter run -d chrome) — the exception below is thrown at runtime when the .riv file is loaded.

Stack trace (abbreviated):

══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞══════════════════════
The following TypeErrorImpl was thrown:
Unexpected null value.

package:rive/src/file_loader.dart 91:23                 <fn>
package:rive_native/src/rive.dart 301:3                 <fn>
package:rive_native/src/web/rive_web.dart 99:1          <fn>
══════════════════════════════════════════════════════════════════

Source .riv/.rev file

We are unable to share the .riv file publicly as it is proprietary. The issue reproduces with our internal animation assets. We can privately share the file at hello@rive.app if needed — however, we believe this is a general JS-web-runtime issue rather than asset-specific, since the same file works perfectly under WASM.

Expected behavior

The .riv file should load and render successfully on Flutter web builds compiled to JavaScript (without --wasm), just as it does when compiled with --wasm. The Rive runtime should handle both web compilation targets without throwing null errors.

Screenshots

N/A — the error occurs during file loading, before any animation is rendered.

Device & Versions (please complete the following information)

  • Device: Chrome (Desktop web)
  • OS: macOS 25.3.0 (Darwin)
  • rive version: 0.14.3 (latest)
  • rive_native version: 0.1.3
  • Flutter Version:
Flutter 3.38.9 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 67323de285 (5 weeks ago) • 2026-01-28 13:43:12 -0800
Engine • hash 5eb06b7ad5bb8cbc22c5230264c7a00ceac7674b (revision 587c18f873)
Tools • Dart 3.10.8 • DevTools 2.51.1
  • Web compilation: dart2js / DDC (non-WASM)

Additional context

  • The issue is specifically a WASM vs. JS compilation discrepancy. When --wasm is passed to flutter build web, the Rive file loads fine. Without --wasm, the null error is thrown.
  • The null value originates in rive_native's web-specific code path (rive_web.dart:99), suggesting the JS interop or web runtime initialization returns null where the WASM path returns a valid object.
  • We are on the latest versions of both rive (0.14.3) and rive_native (0.1.3).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions