Skip to content
pubscout

flutter_js

0.8.7, released 10 months ago by an unverified publisher

JavaScript engine for Flutter using QuickJS and JavaScriptCore via FFI.

$ flutter pub add flutter_js
Source repository

What it does

Provides a unified JavaScript runtime across Android, iOS, Windows, macOS, and Linux using native engines (QuickJS and JavaScriptCore). Allows evaluating JavaScript code, handling promises, and executing HTTP requests (xhr/fetch) synchronously through Dart FFI.

AI-written summary of version 0.8.7, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to run JavaScript libraries natively within your Flutter app without a hidden WebView
  • You want to share business logic, validation rules, or scripts between your web app and mobile/desktop apps
  • You need to evaluate JavaScript and communicate between Dart and JS via channels

Skip it when

  • You require a full browser DOM environment (consider WebView alternatives instead)
  • You want to avoid native engine dependencies or binary size increases

Strengths

  • Unified API for QuickJS and JavaScriptCore across multiple platforms
  • Supports fetch, xhr, and promises out of the box
  • Small APK footprint compared to V8-based alternatives

Weaknesses

  • Requires platform-specific configuration for release builds (such as Proguard rules on Android or entitlements on macOS)
  • Debugging JavaScript on certain platforms requires specific configuration

Setup

Kind
Plugin (native code)
Effort
Medium
Code generation
No
Direct dependencies
3

Requires changing the minimum Android SDK version to 21 and setting up Proguard rules for Android release builds. macOS requires entitlements for network and JIT access if making HTTP calls.

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

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _jsResult = '';
  late JavascriptRuntime flutterJs;
  @override
  void initState() {
    super.initState();
    flutterJs = getJavascriptRuntime();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('FlutterJS Example'),
        ),
        body: Center(
          child: Text('JS Evaluate Result: \$_jsResult\n'),
        ),
        floatingActionButton: FloatingActionButton(
          child: Icon(Icons.play_arrow),
          onPressed: () async {
            JsEvalResult jsResult = flutterJs.evaluate("Math.trunc(Math.random() * 100).toString();");
            setState(() {
              _jsResult = jsResult.stringResult;
            });
          },
        ),
      ),
    );
  }
}

Alternatives

Packages that do the same job and could replace flutter_js.

  • jsf

    High-performance JavaScript engine plugin for Flutter with QuickJS.

  • wasm_interop

    Dart wrapper for the WebAssembly JavaScript API.

Works with

Packages commonly used together with flutter_js: ones it builds on, ones built on it, and its own family.