Skip to content

Commit

Permalink
fix: handle navigation in webview
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Nov 1, 2020
1 parent fcd416d commit d940f3b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/widgets/html_view.dart
@@ -1,6 +1,7 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:git_touch/models/theme.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:provider/provider.dart';
import 'package:webview_flutter/webview_flutter.dart';

Expand Down Expand Up @@ -33,6 +34,7 @@ class HtmlView extends StatefulWidget {
class _HtmlViewState extends State<HtmlView> {
double height;
WebViewController controller;
var loaded = false;

@override
Widget build(BuildContext context) {
Expand All @@ -56,6 +58,15 @@ class _HtmlViewState extends State<HtmlView> {
height = double.parse(res);
});
},
navigationDelegate: (request) {
if (loaded) {
launchUrl(request.url); // TODO:
return NavigationDecision.prevent;
} else {
loaded = true;
return NavigationDecision.navigate;
}
},
),
);
}
Expand Down

0 comments on commit d940f3b

Please sign in to comment.