redirect to app from browser flutter code example

Example 1: open link with button flutter

import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

void main() {
  runApp(new Scaffold(
    body: new Center(
      child: new RaisedButton(
        onPressed: _launchURL,
        child: new Text('Show Flutter homepage'),
      ),
    ),
  ));
}

_launchURL() async {
  const url = 'https://flutter.io';
  if (await canLaunch(url)) {
    await launch(url);
  } else {
    throw 'Could not launch $url';
  }
}

Example 2: how to launch url in flutter web

import 'dart:html' as html;
void htmlOpenLink() {
  String url = 'https://flutter.dev'; 
  html.window.open(url, '_blank');
}

Tags:

Dart Example