Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to send an SMS in Flutter

Irzum Jafri

Sending an SMS is one of the many common features in mobile applications that provides easy communication with the users and good security services. Flutter applications provide many different ways to send SMS.

Step 1: Creating a Flutter app

To utilize this bundle in the Flutter application, we need to install Flutter in our PC or laptop. Next, we need to make a flutter application utilizing the accompanying code:

 flutter create flutter_app
 cd flutter_app
 flutter analyze
 flutter run lib/main.dart

Step 2: Installing packages

We need to start our code in the lib/main.dart file.

To send an SMS in the Flutter application, we can use the package provided by Flutter named flutter_sms.

To install this package in our Flutter application, we need to run the following code:

flutter pub add flutter_sms

This will add the following line in our pubspec.yaml file indicating that the package has been successfully installed.

  flutter_sms: ^2.3.2

Sometimes the editor needs to be restarted for complete installation, or we need to run the following command in the terminal:

flutter pub get

After complete installation, we need to import the following commands in the dart file where we will write code for sending an SMS.

import 'package:flutter_sms/flutter_sms.dart';

Step 3: Creating a function

The next step is to create a function that will accept messages and the list of recipients’ numbers to whom the message needs to be sent. The function will be called every time the message needs to be sent in the app.

void sending_SMS(String msg, List<String> list_receipents) async {
 String send_result = await sendSMS(message: msg, recipients: list_receipents)
        .catchError((err) {

Step 4: Testing

In our Dart file, the function above needs to be called to send an SMS.

sending_SMS('Hello, this the test message', ['1234512345', '456785678',...])



View all Courses

Keep Exploring