I am with a profile that has the phone icon (and of course contains the cell phone number) and when I press I want the cell phone to dial the phone number.
Is there any way to do it? I am working with dart and flutter.
import 'package:flutter/material.dart';
import 'package:path/path.dart';
import 'package:url_launcher/url_launcher.dart';
class fila_botones extends StatelessWidget {
String celular;
fila_botones(this.celular);
@override
Widget build(BuildContext context) {
final barraiconos = Container(
width: 100.0,
height: 50.0,
decoration: BoxDecoration(
color: Color(0xFFFFFFFF),
),
margin: EdgeInsets.only(
top: 20.0,
left: 20.0,
right: 20.0,
),
child: Row(
children: [
InkWell(
child: Container(
child: Tooltip(
child: Icon(
Icons.call,
size: 50.0,
),
message: 'El celu es: ' + celular.toString()),
margin: EdgeInsets.only(
right: 50.0,
left: 20.0,
),
),
onTap: () {
_launchURL();
}
),
InkWell(
child: Container(
child: Icon(
Icons.map,
size: 50.0,
),
margin: EdgeInsets.only(
right: 50.0,
),
),
onTap: () {
}
,
),
InkWell(
child: Container(
child: Icon(
Icons.print,
size: 50.0,
),
margin: EdgeInsets.only(
right: 50.0,
),
),
onTap: () {
}
,
),
],
),
);
return barraiconos;
}
_launchURL() async {
var url = celular;
print(celular);
if (celular != null){
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}else{
AlertDialog(
content: Text('No contiene numero telefonico'),
);
}
}
}
You can use the url_launcher package Seǵun the same documentation your implementation would look something like this: