From 8c13f111b5696ab922f5abb4ec30e0d866763cbb Mon Sep 17 00:00:00 2001 From: entronad Date: Sat, 13 Aug 2022 11:11:15 +0800 Subject: [PATCH] v2.4.0 --- CHANGELOG.md | 8 +++++ example/lib/main.dart | 1 - lib/flutter_echarts.dart | 77 +++++++++++++++------------------------- pubspec.yaml | 2 +- 4 files changed, 37 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a3efb2..6f5d8bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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** diff --git a/example/lib/main.dart b/example/lib/main.dart index fc4899a..7397a21 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -81,7 +81,6 @@ class _MyHomePageState extends State { appBar: AppBar( title: Text('Echarts Demon'), ), - backgroundColor: Colors.white, body: SingleChildScrollView( child: Center( child: Column( diff --git a/lib/flutter_echarts.dart b/lib/flutter_echarts.dart index 658fe7e..462ce64 100644 --- a/lib/flutter_echarts.dart +++ b/lib/flutter_echarts.dart @@ -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'; @@ -63,10 +59,6 @@ class _EchartsState extends State { String? _currentOption; - // --- FIX_BLINK --- - double _opacity = Platform.isAndroid ? 0.0 : 1.0; - // --- FIX_BLINK --- - @override void initState() { super.initState(); @@ -86,7 +78,7 @@ class _EchartsState extends State { ) : ''; 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); @@ -126,7 +118,7 @@ class _EchartsState extends State { void update(String preOption) async { _currentOption = widget.option; if (_currentOption != preOption) { - await _controller?.evaluateJavascript(''' + await _controller?.runJavascript(''' try { chart.setOption($_currentOption, true); } catch(e) { @@ -141,53 +133,40 @@ class _EchartsState extends State { 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( - 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( + name: 'Messager', + onMessageReceived: (JavascriptMessage javascriptMessage) { + if (widget.onMessage != null) { + widget.onMessage!(javascriptMessage.message); } - ), - ].toSet(), - gestureRecognizers: getGestureRecognizers() - ) + } + ), + ].toSet(), + gestureRecognizers: getGestureRecognizers() ); } } diff --git a/pubspec.yaml b/pubspec.yaml index 67fd95f..a733fcd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: