Skip to content

Unable to avoid unsafe-eval in Flutter web #468

@wenchonglee

Description

@wenchonglee

Description

In my Flutter web deployment, I have to add unsafe-eval to CSP.
This is despite the FAQ section saying otherwise. (which I presume is for rive-web)

Reproduction

I created a simple project and deployed it here: https://unsafe-eval.pages.dev/
You should be able to open dev tools and see the following error:

Image

The project is created with flutter create and adding rive, along with the simple code:

import 'package:flutter/material.dart';
import 'package:rive/rive.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: Scaffold(
        body: Column(
          children: [
            Text('Demo'),
            SizedBox.square(
              dimension: 500,
              child: RiveAnimation.network(
                'https://cdn.rive.app/animations/vehicles.riv',
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Along with the inline CSP in index.html:

<meta http-equiv="Content-Security-Policy"
    content="script-src 'self' 'wasm-unsafe-eval' 'unsafe-inline' www.gstatic.com cdn.jsdelivr.net">

I may have missed something here but is there a workaround to avoid adding unsafe-eval?

Versions

  • Flutter version 3.29.2
  • Rive version 0.13.20

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