Skip to content

Commit

Permalink
v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
entronad committed Aug 13, 2022
1 parent adf5f92 commit 8c13f11
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 51 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 2.4.0

**2022-08-13**

- Upgrade webview_flutter to 3.0.4
- Upgrade Echarts to 5.3.3
- Set chart widget's background color to transparent, and remove workarounds.

## 2.3.0

**2021-10-27**
Expand Down
1 change: 0 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class _MyHomePageState extends State<MyHomePage> {
appBar: AppBar(
title: Text('Echarts Demon'),
),
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Center(
child: Column(
Expand Down
77 changes: 28 additions & 49 deletions lib/flutter_echarts.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
library flutter_echarts;

// --- FIX_BLINK ---
import 'dart:io' show Platform;
// --- FIX_BLINK ---

import 'package:flutter/widgets.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/foundation.dart';
Expand Down Expand Up @@ -63,10 +59,6 @@ class _EchartsState extends State<Echarts> {

String? _currentOption;

// --- FIX_BLINK ---
double _opacity = Platform.isAndroid ? 0.0 : 1.0;
// --- FIX_BLINK ---

@override
void initState() {
super.initState();
Expand All @@ -86,7 +78,7 @@ class _EchartsState extends State<Echarts> {
)
: '';
final themeStr = this.widget.theme != null ? '\'${this.widget.theme}\'' : 'null';
await _controller?.evaluateJavascript('''
await _controller?.runJavascript('''
$echartsScript
$extensionsStr
var chart = echarts.init(document.getElementById('chart'), $themeStr);
Expand Down Expand Up @@ -126,7 +118,7 @@ class _EchartsState extends State<Echarts> {
void update(String preOption) async {
_currentOption = widget.option;
if (_currentOption != preOption) {
await _controller?.evaluateJavascript('''
await _controller?.runJavascript('''
try {
chart.setOption($_currentOption, true);
} catch(e) {
Expand All @@ -141,53 +133,40 @@ class _EchartsState extends State<Echarts> {
update(oldWidget.option);
}

// --- FIX_IOS_LEAK ---
@override
void dispose() {
if (Platform.isIOS) {
_controller?.clearCache();
}
_controller?.clearCache();
super.dispose();
}
// --- FIX_IOS_LEAK ---

@override
Widget build(BuildContext context) {
// --- FIX_BLINK ---
return Opacity(
opacity: _opacity,
// --- FIX_BLINK ---
child: WebView(
initialUrl: htmlBase64,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller = webViewController;
},
onPageFinished: (String url) {
// --- FIX_BLINK ---
if (Platform.isAndroid) {
setState(() { _opacity = 1.0; });
}
// --- FIX_BLINK ---
init();
},
onWebResourceError: (e) {
if (widget.onWebResourceError != null) {
widget.onWebResourceError!(_controller!, Exception(e));
}
},
javascriptChannels: <JavascriptChannel>[
JavascriptChannel(
name: 'Messager',
onMessageReceived: (JavascriptMessage javascriptMessage) {
if (widget.onMessage != null) {
widget.onMessage!(javascriptMessage.message);
}
return WebView(
backgroundColor: Color(0x00000000),
initialUrl: htmlBase64,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller = webViewController;
},
onPageFinished: (String url) {
init();
},
onWebResourceError: (e) {
if (widget.onWebResourceError != null) {
widget.onWebResourceError!(_controller!, Exception(e));
}
},
javascriptChannels: <JavascriptChannel>[
JavascriptChannel(
name: 'Messager',
onMessageReceived: (JavascriptMessage javascriptMessage) {
if (widget.onMessage != null) {
widget.onMessage!(javascriptMessage.message);
}
),
].toSet(),
gestureRecognizers: getGestureRecognizers()
)
}
),
].toSet(),
gestureRecognizers: getGestureRecognizers()
);
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_echarts
description: A data visualization charts library, based on Apache ECharts, able to build advanced charts like WebGL 3D, GIS map, etc.
version: 2.3.0
version: 2.4.0
homepage: https://github.com/entronad/flutter_echarts

environment:
Expand Down

0 comments on commit 8c13f11

Please sign in to comment.