Skip to content

Instantly share code, notes, and snippets.

Last active April 13, 2023 19:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Open up Stably Ramp Trade page in a WebView and continue checkout in user's mobile browser when proceed is clicked
import 'package:url_launcher/url_launcher.dart';
class _WebViewExampleState extends State<WebViewExample> {
final String url = '';
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Webview Example'),
body: WebView(
initialUrl: url,
javascriptMode: JavascriptMode.unrestricted,
navigationDelegate: (NavigationRequest request) {
if (request.url.startsWith('browser://')) {
_launchURL(request.url.replaceFirst('browser://', 'https://'));
return NavigationDecision.prevent;
return NavigationDecision.navigate;
void _launchURL(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment