Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.3K
Visualizações
How can I dial the phone from Flutter?

I am building a Flutter app, and I'd like to dial a phone number in response to a button tap. What's the best way to do this?

Thanks!

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

This method will open the dialer :

_launchCaller() async {
    const url = "tel:1234567";   
    if (await canLaunch(url)) {
       await launch(url);
    } else {
      throw 'Could not launch $url';
    }   
}

EDIT:

In case anybody facing errors:

Add url_launcher: in the pubspec.yaml & run flutter get

Also import 'package:url_launcher/url_launcher.dart';

over 4 years ago · Santiago Trujillo Relatório

0

Typically, to interact with the underlying platform, you have to write platform specific code and communicate with the same using platform channels. However, Flutter provides some points of integration with the platform out of the box. To dial the phone for instance, you can use the UrlLauncher.launch API with the tel scheme to dial the phone.

Something like UrlLauncher.launch("tel://<phone_number>"); should work fine on all platforms.

Do note that this will not work in the simulators. So make sure you are using an actual device to test this.

over 4 years ago · Santiago Trujillo Relatório

0

You can use the url_launcher widget (https://pub.dev/packages/url_launcher)

  1. Add this to your package's pubspec.yaml file: dependencies: url_launcher: ^5.7.10

  2. Install it: $ flutter pub get

  3. Import it import 'package:url_launcher/url_launcher.dart';

  4. Inside your class, define this method so you can call from any action in your code:

     Future<void> _makePhoneCall(String url) async {
     if (await canLaunch(url)) {
       await launch(url);
     } else {
       throw 'Could not launch $url';
     }
    

    }

  5. inside the build widget:

     IconButton(icon: new Icon(Icons.phone),
        onPressed: () 
        {
           setState(() {
              _makePhoneCall('tel:0597924917');
           });
        },
      ),
    

Note 1: you should write the phone number with prefix 'tel': 'tel:0123456789'

Note 2: sometimes it will not work well until you close the app in your mobile and reopen it, so flutter can inject the code of the new widget successfully.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda