{"id":93,"date":"2024-07-04T11:22:38","date_gmt":"2024-07-04T11:22:38","guid":{"rendered":"https:\/\/flutterfever.com\/news\/?p=93"},"modified":"2024-07-04T11:22:38","modified_gmt":"2024-07-04T11:22:38","slug":"how-to-navigate-link-in-new-tab-in-flutter-web-without-android","status":"publish","type":"post","link":"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/","title":{"rendered":"How to navigate link in new tab in flutter web without android"},"content":{"rendered":"\n<p>In Flutter web, you can navigate to a link in a new tab without relying on Android-specific code by using the <code>url_launcher<\/code> package. Here&#8217;s how you can do it:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Add the <code>url_launcher<\/code> package to your <code>pubspec.yaml<\/code> file:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>dependencies:\n  flutter:\n    sdk: flutter\n  url_launcher: ^6.0.9\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Update your Dart code to use <code>url_launcher<\/code>:<\/strong>dart<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter\/material.dart';\nimport 'package:url_launcher\/url_launcher.dart';\n\nvoid main() {\n  runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      home: Scaffold(\n        appBar: AppBar(\n          title: Text('Open Link in New Tab Example'),\n        ),\n        body: Center(\n          child: ElevatedButton(\n            onPressed: _launchURL,\n            child: Text('Open Flutter Website'),\n          ),\n        ),\n      ),\n    );\n  }\n\n  void _launchURL() async {\n    const url = 'https:\/\/flutter.dev';\n    if (await canLaunch(url)) {\n      await launch(\n        url,\n        webOnlyWindowName: '_blank', \/\/ This will open the link in a new tab\n      );\n    } else {\n      throw 'Could not launch $url';\n    }\n  }\n}\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Explanation:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>url_launcher<\/code> package provides a method <code>launch<\/code> which can be used to open URLs.<\/li>\n\n\n\n<li>The <code>webOnlyWindowName: '_blank'<\/code> parameter ensures that the link opens in a new tab when running in a web environment.<\/li>\n\n\n\n<li>The <code>canLaunch<\/code> method checks if the URL can be launched.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>By using the <code>url_launcher<\/code> package and specifying <code>webOnlyWindowName: '_blank'<\/code>, you ensure that the URL opens in a new tab on Flutter web, providing a platform-independent solution.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Flutter web, you can navigate to a link in a new tab without relying on Android-specific code by using the url_launcher package. Here&#8217;s how you can do it: Update your Dart code to use url_launcher:dart By using the url_launcher package and specifying webOnlyWindowName: &#8216;_blank&#8217;, you ensure that the URL opens in a new tab &#8230; <a title=\"How to navigate link in new tab in flutter web without android\" class=\"read-more\" href=\"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/\" aria-label=\"Read more about How to navigate link in new tab in flutter web without android\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":78,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[6,5],"class_list":["post-93","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-flutter","tag-flutter-app-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to navigate link in new tab in flutter web without android<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to navigate link in new tab in flutter web without android\" \/>\n<meta property=\"og:description\" content=\"In Flutter web, you can navigate to a link in a new tab without relying on Android-specific code by using the url_launcher package. Here&#8217;s how you can do it: Update your Dart code to use url_launcher:dart By using the url_launcher package and specifying webOnlyWindowName: &#039;_blank&#039;, you ensure that the URL opens in a new tab ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/\" \/>\n<meta property=\"og:site_name\" content=\"Flutter News and Job Updates\" \/>\n<meta property=\"article:published_time\" content=\"2024-07-04T11:22:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/flutterfever.com\/news\/wp-content\/uploads\/2024\/07\/image-10.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1256\" \/>\n\t<meta property=\"og:image:height\" content=\"584\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Dileep Gupta\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dileep Gupta\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/\",\"url\":\"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/\",\"name\":\"How to navigate link in new tab in flutter web without android\",\"isPartOf\":{\"@id\":\"https:\/\/flutterfever.com\/news\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/flutterfever.com\/news\/wp-content\/uploads\/2024\/07\/image-10.png\",\"datePublished\":\"2024-07-04T11:22:38+00:00\",\"dateModified\":\"2024-07-04T11:22:38+00:00\",\"author\":{\"@id\":\"https:\/\/flutterfever.com\/news\/#\/schema\/person\/ad598819a9e5c65eb967af1266e11a2d\"},\"breadcrumb\":{\"@id\":\"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/#primaryimage\",\"url\":\"https:\/\/flutterfever.com\/news\/wp-content\/uploads\/2024\/07\/image-10.png\",\"contentUrl\":\"https:\/\/flutterfever.com\/news\/wp-content\/uploads\/2024\/07\/image-10.png\",\"width\":1256,\"height\":584,\"caption\":\"Understanding Flutter Widgets\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/flutterfever.com\/news\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to navigate link in new tab in flutter web without android\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/flutterfever.com\/news\/#website\",\"url\":\"https:\/\/flutterfever.com\/news\/\",\"name\":\"Flutter News and Job Updates\",\"description\":\"Flutter News, Hiring, Job, Recruitment, Freelancing and more\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/flutterfever.com\/news\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/flutterfever.com\/news\/#\/schema\/person\/ad598819a9e5c65eb967af1266e11a2d\",\"name\":\"Dileep Gupta\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/flutterfever.com\/news\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8650ac6fbcef35c65894bd4e4f8b103d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8650ac6fbcef35c65894bd4e4f8b103d?s=96&d=mm&r=g\",\"caption\":\"Dileep Gupta\"},\"sameAs\":[\"https:\/\/flutterfever.com\/news\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to navigate link in new tab in flutter web without android","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/","og_locale":"en_US","og_type":"article","og_title":"How to navigate link in new tab in flutter web without android","og_description":"In Flutter web, you can navigate to a link in a new tab without relying on Android-specific code by using the url_launcher package. Here&#8217;s how you can do it: Update your Dart code to use url_launcher:dart By using the url_launcher package and specifying webOnlyWindowName: '_blank', you ensure that the URL opens in a new tab ... Read more","og_url":"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/","og_site_name":"Flutter News and Job Updates","article_published_time":"2024-07-04T11:22:38+00:00","og_image":[{"width":1256,"height":584,"url":"https:\/\/flutterfever.com\/news\/wp-content\/uploads\/2024\/07\/image-10.png","type":"image\/png"}],"author":"Dileep Gupta","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Dileep Gupta","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/","url":"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/","name":"How to navigate link in new tab in flutter web without android","isPartOf":{"@id":"https:\/\/flutterfever.com\/news\/#website"},"primaryImageOfPage":{"@id":"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/#primaryimage"},"image":{"@id":"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/#primaryimage"},"thumbnailUrl":"https:\/\/flutterfever.com\/news\/wp-content\/uploads\/2024\/07\/image-10.png","datePublished":"2024-07-04T11:22:38+00:00","dateModified":"2024-07-04T11:22:38+00:00","author":{"@id":"https:\/\/flutterfever.com\/news\/#\/schema\/person\/ad598819a9e5c65eb967af1266e11a2d"},"breadcrumb":{"@id":"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/#primaryimage","url":"https:\/\/flutterfever.com\/news\/wp-content\/uploads\/2024\/07\/image-10.png","contentUrl":"https:\/\/flutterfever.com\/news\/wp-content\/uploads\/2024\/07\/image-10.png","width":1256,"height":584,"caption":"Understanding Flutter Widgets"},{"@type":"BreadcrumbList","@id":"https:\/\/flutterfever.com\/news\/how-to-navigate-link-in-new-tab-in-flutter-web-without-android\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/flutterfever.com\/news\/"},{"@type":"ListItem","position":2,"name":"How to navigate link in new tab in flutter web without android"}]},{"@type":"WebSite","@id":"https:\/\/flutterfever.com\/news\/#website","url":"https:\/\/flutterfever.com\/news\/","name":"Flutter News and Job Updates","description":"Flutter News, Hiring, Job, Recruitment, Freelancing and more","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/flutterfever.com\/news\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/flutterfever.com\/news\/#\/schema\/person\/ad598819a9e5c65eb967af1266e11a2d","name":"Dileep Gupta","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/flutterfever.com\/news\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8650ac6fbcef35c65894bd4e4f8b103d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8650ac6fbcef35c65894bd4e4f8b103d?s=96&d=mm&r=g","caption":"Dileep Gupta"},"sameAs":["https:\/\/flutterfever.com\/news"]}]}},"_links":{"self":[{"href":"https:\/\/flutterfever.com\/news\/wp-json\/wp\/v2\/posts\/93","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/flutterfever.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/flutterfever.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/flutterfever.com\/news\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/flutterfever.com\/news\/wp-json\/wp\/v2\/comments?post=93"}],"version-history":[{"count":1,"href":"https:\/\/flutterfever.com\/news\/wp-json\/wp\/v2\/posts\/93\/revisions"}],"predecessor-version":[{"id":94,"href":"https:\/\/flutterfever.com\/news\/wp-json\/wp\/v2\/posts\/93\/revisions\/94"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/flutterfever.com\/news\/wp-json\/wp\/v2\/media\/78"}],"wp:attachment":[{"href":"https:\/\/flutterfever.com\/news\/wp-json\/wp\/v2\/media?parent=93"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/flutterfever.com\/news\/wp-json\/wp\/v2\/categories?post=93"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/flutterfever.com\/news\/wp-json\/wp\/v2\/tags?post=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}