Skip to content

Commit

Permalink
Revert "Add autokeepalive"
Browse files Browse the repository at this point in the history
This reverts commit 090c612.
  • Loading branch information
rick.van.melis committed Oct 28, 2020
1 parent 090c612 commit 4be879b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 66 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,3 @@ lib/generated_plugin_registrant.dart
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
.idea/workspace.xml
.idea/workspace.xml
.idea/workspace.xml
8 changes: 2 additions & 6 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions flutter_echarts.iml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/debug/.pub" />
<excludeFolder url="file://$MODULE_DIR$/debug/build" />
<excludeFolder url="file://$MODULE_DIR$/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/example/build" />
</content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Flutter Plugins" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>
108 changes: 51 additions & 57 deletions lib/flutter_echarts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import 'echarts_script.dart' show echartsScript;

/// <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, target-densitydpi=device-dpi" /><style type="text/css">body,html,#chart{height: 100%;width: 100%;margin: 0px;}div {-webkit-tap-highlight-color:rgba(255,255,255,0);}</style></head><body><div id="chart" /></body></html>
/// 'data:text/html;base64,' + base64Encode(const Utf8Encoder().convert( /* STRING ABOVE */ ))
const htmlBase64 =
'data:text/html;base64,PCFET0NUWVBFIGh0bWw+PGh0bWw+PGhlYWQ+PG1ldGEgY2hhcnNldD0idXRmLTgiPjxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lkdGgsIGluaXRpYWwtc2NhbGU9MS4wLCBtYXhpbXVtLXNjYWxlPTEuMCwgbWluaW11bS1zY2FsZT0xLjAsIHVzZXItc2NhbGFibGU9MCwgdGFyZ2V0LWRlbnNpdHlkcGk9ZGV2aWNlLWRwaSIgLz48c3R5bGUgdHlwZT0idGV4dC9jc3MiPmJvZHksaHRtbCwjY2hhcnR7aGVpZ2h0OiAxMDAlO3dpZHRoOiAxMDAlO21hcmdpbjogMHB4O31kaXYgey13ZWJraXQtdGFwLWhpZ2hsaWdodC1jb2xvcjpyZ2JhKDI1NSwyNTUsMjU1LDApO308L3N0eWxlPjwvaGVhZD48Ym9keT48ZGl2IGlkPSJjaGFydCIgLz48L2JvZHk+PC9odG1sPg==';
const htmlBase64 = 'data:text/html;base64,PCFET0NUWVBFIGh0bWw+PGh0bWw+PGhlYWQ+PG1ldGEgY2hhcnNldD0idXRmLTgiPjxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lkdGgsIGluaXRpYWwtc2NhbGU9MS4wLCBtYXhpbXVtLXNjYWxlPTEuMCwgbWluaW11bS1zY2FsZT0xLjAsIHVzZXItc2NhbGFibGU9MCwgdGFyZ2V0LWRlbnNpdHlkcGk9ZGV2aWNlLWRwaSIgLz48c3R5bGUgdHlwZT0idGV4dC9jc3MiPmJvZHksaHRtbCwjY2hhcnR7aGVpZ2h0OiAxMDAlO3dpZHRoOiAxMDAlO21hcmdpbjogMHB4O31kaXYgey13ZWJraXQtdGFwLWhpZ2hsaWdodC1jb2xvcjpyZ2JhKDI1NSwyNTUsMjU1LDApO308L3N0eWxlPjwvaGVhZD48Ym9keT48ZGl2IGlkPSJjaGFydCIgLz48L2JvZHk+PC9odG1sPg==';

class Echarts extends StatefulWidget {
Echarts({
Expand Down Expand Up @@ -47,9 +46,7 @@ class Echarts extends StatefulWidget {
_EchartsState createState() => _EchartsState();
}

class _EchartsState extends State<Echarts> with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;
class _EchartsState extends State<Echarts> {
WebViewController _controller;

String _currentOption;
Expand All @@ -66,13 +63,11 @@ class _EchartsState extends State<Echarts> with AutomaticKeepAliveClientMixin {

void init() async {
final extensionsStr = this.widget.extensions.length > 0
? this
.widget
.extensions
.reduce((value, element) => (value ?? '') + '\n' + (element ?? ''))
: '';
final themeStr =
this.widget.theme != null ? '\'${this.widget.theme}\'' : 'null';
? this.widget.extensions.reduce(
(value, element) => (value ?? '') + '\n' + (element ?? '')
)
: '';
final themeStr = this.widget.theme != null ? '\'${this.widget.theme}\'' : 'null';
await _controller?.evaluateJavascript('''
$echartsScript
$extensionsStr
Expand Down Expand Up @@ -115,53 +110,52 @@ class _EchartsState extends State<Echarts> with AutomaticKeepAliveClientMixin {

@override
Widget build(BuildContext context) {
super.build(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;
});
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();
},
javascriptChannels: <JavascriptChannel>[
JavascriptChannel(
name: 'Messager',
onMessageReceived: (JavascriptMessage javascriptMessage) {
widget?.onMessage(javascriptMessage.message);
}
// --- FIX_BLINK ---
init();
},
javascriptChannels: <JavascriptChannel>[
JavascriptChannel(
name: 'Messager',
onMessageReceived: (JavascriptMessage javascriptMessage) {
widget?.onMessage(javascriptMessage.message);
}),
].toSet(),
gestureRecognizers: widget.captureAllGestures
? (Set()
..add(Factory<VerticalDragGestureRecognizer>(() {
return VerticalDragGestureRecognizer()
..onStart = (DragStartDetails details) {}
..onUpdate = (DragUpdateDetails details) {}
..onDown = (DragDownDetails details) {}
..onCancel = () {}
..onEnd = (DragEndDetails details) {};
}))
..add(Factory<HorizontalDragGestureRecognizer>(() {
return HorizontalDragGestureRecognizer()
..onStart = (DragStartDetails details) {}
..onUpdate = (DragUpdateDetails details) {}
..onDown = (DragDownDetails details) {}
..onCancel = () {}
..onEnd = (DragEndDetails details) {};
})))
: null,
));
),
].toSet(),
gestureRecognizers: widget.captureAllGestures
? (Set()
..add(Factory<VerticalDragGestureRecognizer>(() {
return VerticalDragGestureRecognizer()
..onStart = (DragStartDetails details) {}
..onUpdate = (DragUpdateDetails details) {}
..onDown = (DragDownDetails details) {}
..onCancel = () {}
..onEnd = (DragEndDetails details) {};
}))
..add(Factory<HorizontalDragGestureRecognizer>(() {
return HorizontalDragGestureRecognizer()
..onStart = (DragStartDetails details) {}
..onUpdate = (DragUpdateDetails details) {}
..onDown = (DragDownDetails details) {}
..onCancel = () {}
..onEnd = (DragEndDetails details) {};
})))
: null,
)
);
}
}

0 comments on commit 4be879b

Please sign in to comment.