How to reload browser tab in a Flutter Web Application - flutter

I have a Flutter Application running on web and I need to reload the browser tab programmatically, and I wonder if there is something similarly with html.window.close() but for reload. Is there any way to do this in Flutter?

Use location.reload method
import 'package:universal_html/html.dart' as html;
FlatButton(
child: Text('Refresh'),
onPressed: () {
html.window.location.reload();
},
),

Related

how can I launch Differernt URL in different elevated button in flutter

want to launch URL in ELEVATEDBUTTON. there are too many button for launch too many URL how can I do this in flutter??
I can't understand how can I do this. can anyone solve this problem
you can map the list while rendering on ui.
...urlList
.map(
(e) => ElevatedButton(
onPressed: () {
launchUrl(Uri.parse(e)); //use .tryParse
},
child: Text("$e"),
),
)
.toList(),
You may create a model class with label and string url.

How do I make an icon clickable and redirect it to a URL in flutter

So I have my app in which it has a section with some icons, and I want to make those icons clickable and redirect to a url of my choice. I have tried using url_launcher: ^6.1.6 and url_launcher: ^5.7.8 (tnis one at least took me to a blank page). I don't know what to do now. the code of the link looks like this:
and the code to make the icon clickable is as follows:
And the app looks like this:
I want to make the it so when you click the icon it redirects you to a web page
like I see, what you using to implement the url_launcher code is deprecated, the canLaunch() is deprecated, you need to use canLaunchUri(), or you can simply try the following.
using the url_launcher package, so let's say you have your icons like this:
IconButton(
onPressed: () async {
await goToWebPage("https://flutter.dev");
},
icon: Icon(Icons.add)
),
IconButton(
onPressed: () async {
await goToWebPage("https://instagram.com");
},
icon: Icon(Icons.done)
)
you can simply implement your method, like this:
Future<void> goToWebPage(String urlString) async {
final Uri _url = Uri.parse(urlString);
if (!await launchUrl(_url)) {
throw 'Could not launch $_url';
}
}
this will try to open the https://flutter.dev link in the browser, if there are any problems, it will throw an exception

Flutter go to another page with GetX using BottomAppBar

I try go to another page using bottom app bar button with code under onPressed like this:
TextButton(
onPressed: () {
Get.toNamed('/Register');
},
child: const Text("REGISTER"));
But nothing is changed, page is not refreshed. Why? How to do it?

Flutter webpage navigation

How to get following result in flutter web app using Getx package
On tapping the container in intiating screen, I wish to pass parameters in following fashion ( 2 variable parameters and 1 fixed parameter i.e. product) which should open webpage with following url
https://myapp.local/variableParameter1/variableParameter2/product
Above link should be without # and also when user opens above link, should lead to (ProductScreen) with 2 parameters being passed as arguments
My code is structured in following fashion and works well on mobile devices.
Part of intiating screen
GestureDetector(
child: Container(
//some content inside
),
onTap: () {
Get.toNamed(
'/product/$variableParameter1/$variableParameter2',
);
},
)
Part of main.dart file
GetPage(
name: '/productscreen/variableparameter1/variableparameter1',
page: () => ProductScreen(),
binding: ProductScreenBinding(),
),
Part of controllers for ProductScreen
class ProductController extends GetxController {
var screenprm1 =Get.arguments[0].toString().obs;
var screenprm2 =Get.arguments[1].toString().obs;
}

Remove url bar from chromeSafariBrowser in flutter_inappwebview

I am using ChromeSafariBrowser class of flutter_inappwebview to show the webview which contains videos. I am using this class cause it supports pip and also shows media controls on video play which most of dependencies doesnt provide. Now I want to remove the url bar from the top, how can i achieve it?
Any help is appreciated, thanks in advance..
I want to remove the rectangular marked area in this picture
Following is my sample code
RaisedButton(
onPressed: () async {
await widget.browser.open(
url: "https://player.vimeo.com/api/demo",
options: ChromeSafariBrowserClassOptions(
android: AndroidChromeCustomTabsOptions(
addDefaultShareMenuItem: false,
enableUrlBarHiding:true,
toolbarBackgroundColor: "#000000"
),
ios: IOSSafariOptions(
barCollapsingEnabled: true,
preferredBarTintColor: "#000000"
)
),
);
},
child: Text("Open Chrome Safari Browser")
)