How to make a phone call from a flutter app

后端 未结 7 905
迷失自我
迷失自我 2020-12-03 00:39

I try to make a phone call from my Flutter app. With the following code:

UrlLauncher.launch(\'tel: xxxxxxxx\');

I found this Function on the

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-03 01:10

    If you are not getting any action on the click of the button, So this is happening because of this. So this is happening because you might not have add tel:// before the number.

    Do it this way

    Full code is given below

    launch(('tel://${mobile_no}'));       //launch(('tel://99999xxxxx'));
    

    1) in pubspec.yaml

    dependencies:
      flutter:
        sdk: flutter
    
    url_launcher: ^5.4.10
    

    2) Import wherever you want to use

    import 'package:url_launcher/url_launcher.dart';
    

    3) final you call

    onPressed: () {
      launch(('tel://${item.mobile_no}'));
    },
    

提交回复
热议问题