Skip to content

Commit

Permalink
fix blink;
Browse files Browse the repository at this point in the history
  • Loading branch information
entronad committed Mar 23, 2020
1 parent 52f0a74 commit ccda409
Showing 1 changed file with 50 additions and 36 deletions.
86 changes: 50 additions & 36 deletions lib/flutter_echarts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class _EchartsState extends State<Echarts> {

String _currentOption;

// --- FIX_BLINK ---
bool _pageFinished = false;
// --- FIX_BLINK ---

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -88,42 +92,52 @@ class _EchartsState extends State<Echarts> {

@override
Widget build(BuildContext context) {
return WebView(
initialUrl: htmlBase64,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller = webViewController;
},
onPageFinished: (String url) {
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,
// --- FIX_BLINK ---
return Opacity(
opacity: _pageFinished ? 1.0 : 0.0,
// --- FIX_BLINK ---
child: WebView(
initialUrl: htmlBase64,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller = webViewController;
},
onPageFinished: (String url) {
// --- FIX_BLINK ---
setState(() {
_pageFinished = true;
});
// --- 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,
)
);
}
}

0 comments on commit ccda409

Please sign in to comment.