Mahesh Mohotti
Mahesh Mohotti

Reputation: 53

Is there anyway to open a page in new tab in flutter web?

I've created a web app with flutter and I want to open the second screen in a new tab. Is there any way to do that?

Upvotes: 2

Views: 4710

Answers (2)

Muhammad Umair Saqib
Muhammad Umair Saqib

Reputation: 1835

import 'package:universal_html/html.dart' as html;

 static openNewTab({String setUrl, String setTitle}) {
    return html.window.open(
      setUrl,
      setTitle,
    );
  }

Upvotes: 2

daddygames
daddygames

Reputation: 1928

In your current tab view, build the URL for the new page, then launch it using one of these methods:

How do I open an external url in flutter web in new tab or in same tab

Then, configure your app for for reading query parameters. You can then use those parameters to determine the starting view for your app in the new browser tab.

Here is a discussion about ways to handle query parameters:

How can a named route have URL parameters in flutter web?

Alternatively, uni_links is a package that I have used for deep linking. You can also use this as a way to control what view your user sees at a specific link. The package allows your app to listen for URLs, then you can inspect the parts of the URL and take an action based on parameters, such as navigating to a specific view.

Upvotes: 0

Related Questions