i cant call phone number flutter correctly - flutter

Hello i try to build button call phone number when click .but when click appear different number this is "94343832826624531" and this is not my number in database
FlatButton(
onPressed: () => launch("tel:widget.data.mobile1"),
child: new Text("Call me")),
),

Well, you need to use either
FlatButton(
onPressed: () => launch("tel:${widget.data.mobile1}"),
child: new Text("Call me")),
),
Or
FlatButton(
onPressed: () => launch("tel:"+widget.data.mobile1),
child: new Text("Call me")),
),

Related

How to pass Navigator function as a parameter in flutter?

I have this custom widget:
Widget ButtonsFunction(String text , IconData icon,Function action){
return Column(
children: [
ElevatedButton(
onPressed: () => action,
style: ElevatedButton.styleFrom(
padding: EdgeInsets.all(27.0),
primary: Colors.grey[300],
side: BorderSide(color: Colors.grey , width: 0.5),
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15.0)),
),
child: Icon(icon , color: Colors.indigo,),
),
SizedBox(height: 8.0,),
Text(text, style: TextStyle(fontWeight: FontWeight.bold),),
],
);
}
and this call:
ButtonsFunction('Corporate', Icons.wallet,() => Navigator.pushNamed(context,'/CorporateMatters')),
But nothing happen when i click on the button, i've tried to write the button code without the function and it works normally but with this function i cant navigate
Call it directly, change this:
onPressed: () => action,
to this:
onPressed: action,
Inside your custom widget you should trigger the function you are passing.
Like this:
onPressed: () => action(),
or this:
onPressed: () => action.call(),
Remove () => and call directly action and I advise you also to use named parameters for clearer code.
onPressed: action,
I prefer using VoidCallback in this case,
Widget ButtonsFunction(String text, IconData icon, VoidCallback action) {
return Column(
children: [
ElevatedButton(
onPressed: action,
Also note that I am using onPressed: action, instead of creating anonymous function like onPressed: () => action. If you like to do this way, you need to use () to call the method like onPressed: () => action().

How to add search filter option like this image in flutter

I want to add a filter option button without adding a search bar.
ScreenShot
You can do like this
InkWell(
onTap: () =>
child: const Icon(
Icons.tune,
color: Colors.grey,
),
),
Make use of IconButton like below
IconButton(
icon: Icon(Icons.tune),
onPressed: () {},
)

not able to define web links that will open when icon button is pressed in listview builder which is already under expantionbar

(question1) i am not able to think how to pass 3 weblink link ( google.com, yahoo.com, youtube.com) that will open when 3 corresponding icons in topic 1 are pressed in code on :
https://github.com/sandeepnarula999/FlutterProjects/blob/main/ListViewUnderExpansionTile
pls try to share the complete code if u are able to resolve my issue ..as i shared full code above...pls do
not share just steps of how to do coz that may add up to errrors when i try
(question2)
As per below image suggestion when i try to change code from line 7 to 10 in abve code link i get errors.. are u able to get zero error with this below approach in image
Solution : add three Flexible widgets in the Row widget ;)
if (root.children.isEmpty) {
return ListTile(
title: Text(root.title),
subtitle: root.subtitle == null ? null : Text(root.subtitle!),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: IconButton(
onPressed: () {},
icon: const Icon(Icons.auto_stories),
iconSize: 30,
tooltip: 'Documents',
),flex: 1,
),
Flexible(
child: IconButton(
onPressed: () {},
icon: const Icon(Icons.video_collection_rounded),
iconSize: 30,
tooltip: 'Videos',
),
flex: 1,
),
Flexible(
child: IconButton(
onPressed: () {},
icon: const Icon(Icons.favorite),
iconSize: 20,
tooltip: 'Shortlist',
),flex: 1,
),
],
),
);
}
enter image description here

How do I add two icons and multiple actions on a FAB in Flutter?

I want to add two icons on FAB Flutter, one icon will be a map(onPressed show map) and other icon will trigger showBottomModel. A kind of icon switch based floatingActionBar, I don't know if that is possible or please tell me a work around. Thanks.
You can use flutter_speed_dial package/dependency here or try below code hope its help to you.
floatingActionButton: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
FloatingActionButton(
onPressed: () => {},
child: Icon(Icons.person),
),
FloatingActionButton(
onPressed: () => {},
child: Icon(Icons.home),
),
]
),
Your result screen ->

how to do upload image within steps method in flutter

List<Step> steps = [
Step(
isActive: false,
state: StepState.editing,
title: const Text('Id Proof'),
content: Column(
children: <Widget>[
OutlineButton(
onPressed: chooseImage,
child: Text('Choose Image'),),
showImage(),
OutlineButton(
onPressed: startUpload,
child:Text(Upload Image),
),
Text(status,textAlign:TextAlign.center,style:TextStyle(color:Colors.green))
],
),
),
];
Unable to initialize chooseImage, showImage, startUpload. I have tried to initiate above the steps starting. showing errors
Only static members can be accessed in initializers
chooseImage & startUpload are not functions, if you created a function
void chooseImage() {
// add image picking code here
}
then you need to change
onPressed: chooseImage,
to
onPressed: chooseImage(),
if you didn't make those functions you could also do
onPressed: () {
// add image picking code here
}