fl_echarts

A Flutter package that brings the full power of Apache ECharts to your Flutter app via an embedded WebView — no JavaScript knowledge required.

Supported platforms: Android · iOS · macOS · Windows

Unsupported platforms: Web (due to WebView limitations)


Features

  • Render any ECharts chart (line, bar, pie, scatter, candlestick, radar, map, …)
  • Dark mode support
  • Dynamic chart updates without rebuilding the widget
  • Manual showLoading / hideLoading control
  • Custom JavaScript execution
  • Resize API
  • EChartsController for full programmatic control
  • Callbacks: onChartReady, onMessage, onWebViewCreated

Getting started

1. Add the dependency

dependencies:
  fl_echarts: ^0.2.0

2. Platform setup

Android — no extra steps.

iOS / macOS — add to ios/Runner/Info.plist (iOS) or macos/Runner/Info.plist (macOS):

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsLocalNetworking</key>
  <true/>
</dict>

Windows — follow the webview_windows setup (enable the WebView2 runtime).


Usage

Basic chart

import 'package:fl_echarts/fl_echarts.dart';

ECharts(
  height: 300,
  option: {
    'xAxis': {'type': 'category', 'data': ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']},
    'yAxis': {'type': 'value'},
    'series': [
      {'type': 'bar', 'data': [120, 200, 150, 80, 70]},
    ],
  },
)

Using EChartsController

final _controller = EChartsController();

// In your widget
ECharts(
  height: 300,
  controller: _controller,
  option: _myOption,
  onChartReady: () {
    // Chart is rendered and ready
  },
)

// Update the chart data later
await _controller.updateChart(_newOption);

// Show/hide loading overlay
_controller.showLoading(text: 'Fetching data…');
await Future.delayed(const Duration(seconds: 2));
_controller.hideLoading();

// Trigger resize after layout changes
await _controller.resizeChart();

// Run arbitrary JavaScript
await _controller.executeJavaScript('echart.clear();');

// Clean up
_controller.dispose();

Dark mode

ECharts(
  height: 300,
  darkMode: true,
  option: _myOption,
)

Full widget parameters

Parameter Type Default Description
option Map<String, dynamic> required ECharts option object
width double? fills parent Widget width
height double? 400 Widget height
darkMode bool false Enable dark theme
controller EChartsController? — Programmatic control
onChartReady VoidCallback? — Called when chart finishes rendering
onMessage EChartsMessageCallback? — Raw JS→Flutter messages
onWebViewCreated VoidCallback? — Called when WebView is created

ECharts documentation

For the full list of chart types and option fields see the
official ECharts documentation.


License

MIT. See LICENSE.

Libraries

fl_echarts