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")
)
Related
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.
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
Currently when I tap on an image, it should open a web view as the image object has an associated url. I am using the url_launcher library for Flutter, and I have implemented the code as follows:
onTap: () async {
final url = image.url;
if (await canLaunch(url)) {
await launch(
url,
forceSafariVC: true,
forceWebView: true,
enableJavaScript: true,
);
}
},
My understanding is that this launches a WebView, which is an in-app browser rather than taking the user out of the app and into a separate browser app. This works fine, but the page loads much slower and Javascript elements do not work properly (e.g. animated text on websites). On the other hand,
onTap: () async {
final url = banners[index].url;
if (await canLaunch(url)) {
await launch(
url
);
}
},
works much better as it is faster and everything loads in properly, but it opens an external browser, which is not what I want.
Another issue is that I would like to add a Done button on the top left corner of the WebView to completely exit the WebView and return to where I was in the app. I only have a back button on the bottom left (on the Android emulator), that lets me go to the previous page I was at in the browser.
How do I customise the layout of the WebView, if I do not have any access to it? The url_launcher seems to handle the WebView creation internally, so I'm wondering how can I gain access from the above code to add that button?
Thank you!
If you use the native webview in this manner then you can't customise the ui. But instead, since you are displaying image you can use image.network from flutter.
Image.network(imgURL,fit: BoxFit.fill,
loadingBuilder:(BuildContext context, Widget child,ImageChunkEvent loadingProgress) {
if (loadingProgress == null)
return child;
return Center(
child: CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes != null ?
loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes
: null,
),
);
},
),
Or, you can also use official webview plugin from flutter team to create in app web view.
webview_flutter: ^2.3.1
In this approaches if you add a back button in ui you can the use Navigator.pop(context); on onPressed property in button to go back
I want to transite to Instagram profile, when I am tapping on button. I use this library url_launcher. But there I can use only Web Browser for this. What will I do, in order to reach my goal?
To open Native and WebView Instagram:
Add to your iOS/Runner/Info.plist:
<key>LSApplicationQueriesSchemes</key>
<array>
...
<string>instagram</string>
</array>
Install url_launcher ( https://pub.dev/packages/url_launcher )
Import
import 'package:url_launcher/url_launcher.dart';
Create some method like this;
Inside Widget for example:
_launchInstagram() async {
const nativeUrl = "instagram://user?username=severinas_app";
const webUrl = "https://www.instagram.com/severinas_app/";
if (await canLaunch(nativeUrl)) {
await launch(nativeUrl);
} else if (await canLaunch(webUrl)) {
await launch(webUrl);
} else {
print("can't open Instagram");
}
}
Well, I don't know if it's too late, but this works for me using the url_launcher library (tested on android only):
var url = 'https://www.instagram.com/<INSTAGRAM_PROFILE>/';
if (await canLaunch(url)) {
await launch(
url,
universalLinksOnly: true,
);
} else {
throw 'There was a problem to open the url: $url';
}
2022 update:
_launchInstagram() async {
var nativeUrl = "instagram://user?username=balkan.exe";
var webUrl = "https://www.instagram.com/balkan.exe";
try {
await launchUrlString(nativeUrl, mode: LaunchMode.externalApplication);
} catch (e) {
print(e);
await launchUrlString(webUrl, mode: LaunchMode.platformDefault);
}
}
I am not sure if you can launch the profile activity, unless you know the name (which might change in the future). But, if you can try launching the app by using Intent plugin:
Try adding the Intent plugin:
https://pub.dev/packages/intent
Add intent in you in your pubspec.yaml file.
You can call the specific app with the package name (in this case Instagram).
Intent()
..setAction(Action.ACTION_SHOW_APP_INFO)
..putExtra(Extra.EXTRA_PACKAGE_NAME, "instagram package name")
..startActivity().catchError((e) => print(e));
You can also make use Android flutter plugin for Intent:
https://pub.dev/packages/android_intent
This will support for Android :
Use it by specifying action, category, data and extra arguments for the intent. It does not support returning the result of the launched activity
For IOS url_launcher plugin can be used for deep linking
You can create a platform channel and use the intent to achieve that or use social_share package.
Install url_launcher ( https://pub.dev/packages/url_launcher )
They now have a mode parameter, which you set to LaunchMode.externalApplication;
Call it with the regular https url, if they have the app installed it will open the app, otherwise it will open in Safari. Don't worry about doing an app link and a website url, the package and the OS handle it accordingly.
For example, here are my links in our About section of the app to our socials..
SettingsListTileModel(
// This can be any website's url that has a corresponding app, we us it with Twitter, Facebook, Instagram, and Youtube.
onTap: () => launchUrl(
Uri.parse('https://www.instagram.com/forwheel_app/'),
mode: LaunchMode.externalApplication,
),
title: Text(
'Instagram',
style: context.bodyLarge),
),
trailing: Icon(
FontAwesomeIcons.squareArrowUpRight,
),
),
I don't know what is the name of the interactive visual guide that is displayed usually in first launch of mobile application, and how can I add that to my Flutter application?
Thanks
please use this package https://github.com/pyozer/introduction_screen
code snippet
IntroductionScreen(
pages: listPagesViewModel,
onDone: () {
// When done button is press
},
onSkip: () {
// You can also override onSkip callback
},
showSkipButton: true,
skip: const Icon(Icons.skip_next),
next: const Icon(Icons.next),
done: const Text("Done", style: TextStyle(fontWeight: FontWeight.w600))
);