I use url_launcher package in my app for making a call like this:
IconButton(
onPressed: () {
UrlLauncher.launch('tel://${user.phoneNumber}');
},
icon: Icon(
Icons.phone,
color: Color(0XFF01d57f),
),
)
everything works fine in the simulator, but on real app when I have another call apps like Skype, android ask for default app for calling; and if user select Skype by mistake and press "Always use this" every time Skype open for him instead of default call app how can i avoid those third party apps or just reset settings each time user enter the app ?
I also try flutter_phone_direct_caller package but same thing happened :
IconButton(
onPressed: () async {
//set the number here
bool res =
await FlutterPhoneDirectCaller.callNumber(
user.phoneNumber);
},
icon: Icon(
Icons.phone,
color: Color(0XFF01d57f),
),
)
Related
I want to use the audio players package to run audio files on my app,
NOTE:
I use local files in assets file like this
assets\audio\he_has_got_the_packa.mp3
this path file
I try to use AssetSource
// this is an object from AudioPlayer
AudioPlayer player = AudioPlayer();
...
TextButton(
onPressed: () {
player.setSource(AssetSource('assets\audio\he_has_got_the_packa.mp3'));
},
child: Text('to play click here'),
),
but isn't running because asynchronous suspension
I try searching but I don't get content to this thing
you use below code and you issue is fix.
TextButton(
onPressed: () {
player.setSource(AssetSource('sample-15s.mp3')).then((value) {
player.play(AssetSource('sample-15s.mp3'));
});
},
child: Text('to play click here'),
),
also please verify this image also.
Happy Codeing....
Try this
TextButton(
onPressed: () async {
await player.play(AssetSource('assets\audio\he_has_got_the_packa.mp3'));
},
child: Text('to play click here'),
),
Adding await keyboard and making onPressed() async is important.
How to add whatsapp image in floating action button in flutter because whatsapp icon is not in flutter icon list. Tell me a simple method.
Row(
children: [
FloatingActionButton(
child: const Icon(Icons.chat),
backgroundColor: Colors.green.shade800,
onPressed: () {
String url =
"https://wa.me/+923045873730/?text=Hello";
launch(url);
},
),
],
),
Font Awesome has a flutter package that helps with most icons that are not in flutter default icon set, https://pub.dev/packages/font_awesome_flutter. It also includes all icons listed in font Awesome Offical website https://fontawesome.com/icons
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
Row(
children: [
FloatingActionButton(
child: FaIcon(FontAwesomeIcons.whatsapp),
backgroundColor: Colors.green.shade800,
onPressed: () {
String url =
"https://wa.me/+923045873730/?text=Hello";
launch(url);
},
),
],
),
The easiest way that comes to my mind is that downloading the icon image of Whatsapp (from flaticon or other website), adding it to the project's assets and adding it as a child( for example asset image).
I am using flutter for development and I want to send app to background or close it when user clicks on back icon on appbar
I have used this answer for reference but apart from exit(0) is nothing working, which is not recommended in iOS.
I have tried following recommendations from other answers but none of it working on iOS.
Navigator.of(context).pop();
Navigator.of(context).maybePop();
Navigator.of(context, rootNavigator: true).pop(context);
Navigator.pushReplacementNamed(context, '/route');
SystemNavigator.pop();
Navigator.pop(context,true);
SystemChannels.platform.invokeMethod('SystemNavigator.pop');
for android following is working properly.
SystemNavigator.pop();
What should I use to close the app within apple guidelines.
EDIT
SystemNavigator.pop(); gives black screen in iOS.
Try this
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back, color: Colors.black),
onPressed: () => Navigator.of(context).pop(),
),
title: Text("Sample"),
centerTitle: true,
),
i have an issue about the text widget not being able to detect that there is a link.
later I will get a text response from the server as shown. the response is in the form of text as well as a link.
the problem is the text widget on flutter can't detect it. How do I make the link in the text detectable and clickable?
I have read and searched about this but could not find it. because most of the link text must be typed by yourself. while my problem the text is automatically there because it is the response from the server
can anyone help me find an answer?
Thank you in advance
Text widget does not automatically recognise links.
You can, however insert actions to text using the TextSpan widget and url_launcher, somewhat like this:
RichText(
text: TextSpan(
children: [
TextSpan(text: 'some text'),
TextSpan(
text: url,
style: new TextStyle(
color: Colors.blue,
decoration: TextDecoration.underline
),
recognizer: TapGestureRecognizer()
..onTap = () async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
},
),
]
),
)
You can wrap this into a class and make a small LinkText widget for yourself.
What flutter_linkify does is that it automatically detects URLs & email IDs in text and links them.
You can also do this using regex. For eg. for identifying url, you could have something like:
bool _isLink(String input) {
final matcher = new RegExp(
r"(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9#:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9#:%_\+.~#?&//=]*)");
return matcher.hasMatch(input);
}
You will have to, modify this a bit to get the substring and use that as url in text span!
I am using react native navigation Wix V2. Splash screen is my root component. My home page data has been gotten in the splash screen from server and if it has been done successfully it navigates to my home page automatically. I exit from app in home screen as follow:
componentDidAppear() {
handleAndroidBackButton(exitAlert);
}
componentDidDisappear() {
removeAndroidBackButtonHandler();
}
The exitAlert function is:
const exitAlert = () => {
Alert.alert(
'',
'Do you want to Exit?',
[
{text: 'Ask later', onPress: () => console.log('Ask me later pressed')},
{
text: 'No',
onPress: () => console.log('Cancel Pressed'),
style: 'cancel',
},
{text: 'Yes', onPress: () => BackHandler.exitApp()},
],
{cancelable: false},
)
};
The problem is when I exit from app with phone back button my app goes to background (That is correct) but when I open it again it does not start from my root component it shows my home screen. So if there is some changes in server side the web services in my splash screen does not call again and I cannot see the updates in my app.
I found my mistake, I had added android:launchMode="singleTop" this line of code to activity tag of manifest. I deleted it and now my app works correctly.