sms 0.2.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 83


Flutter SMS #

This is an SMS library for flutter.

It only support Android for now (I can't do it for iOS because I don't own Mac).

Getting Started #

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

Installation and Usage #

Once you're familiar with Flutter you may install this package adding sms (0.1.4 or higher) to the dependencies list of the pubspec.yaml file as follow:

    sdk: flutter

  sms: ^0.2.0

Then run the command flutter packages get on the console.

Querying SMS messages #

Add the import statement for sms and create an instance of the SmsQuery class:

import 'package:sms/sms.dart';

void main() {
  SmsQuery query = new SmsQuery();

Getting all SMS messages #

List<SmsMessage> messages = await query.getAllSms;

Note: the use of await keyword means that getAllSms is resolved asynchronously and a Future is retorned.

Filtering SMS messages #

The method querySms from the SmsQuery class returns a list of sms depending of the supplied parameters. For example, for querying all the sms messages sent and received write the followed code:

await query.querySms({
    kinds: [SmsQueryKind.Inbox, SmsQueryKind.Sent]

You can also query all the sms messages sent and received from a specific contact:

await query.querySms({
    address: getContactAddress()

Getting all Threads Conversations #

With SmsQuery you can also get the entire list of conversations:

List<SmsThread> threads = await query.getAllThreads;

Getting the Contact info #

Each conversation thread is related with a Contact. The class Contact contains all the info of a thread contact (address, photo, full name). To get access to Contact class you must import 'package:sms/contact.dart' into your dart file:

import 'package:sms/contact.dart';

void main() {
  Contact contact =;

Querying Contact #

You can also query a contact by its address (phone number):

import 'package:sms/contact.dart';

void main() {
  ContactQuery contacts = new ContactQuery();
  Contact contact = await contacts.queryContact(someAddress());
String getAddress() {...}

The Contact photo #

You can retrieve the photo of the contact (full size or thumbnail):

Uint8List fullSize =;
Uint8List thumbnail = contact.thumbnail.bytes;

User Profile #

Some times it is useful to request basic info of the phone owner, like the contact photo, addresses, etc.

import 'package:sms/contact.dart';

UserProfileProvider provider = new UserProfileProvider();
UserProfile profile = await provider.getUserProfile();

Sending SMS #

What about sending a SMS? All you have to do is to create an instance of the SmsSender class:

import 'package:sms/sms.dart';

void main() {
  SmsSender sender = new SmsSender();
  String address = someAddress();
  sender.sendSms(new SmsMessage(address, 'Hello flutter!'));

To be notified when the message is sent and/or delivered, you must add a listener to your message:

import 'package:sms/sms.dart';

void main() {
  SmsSender sender = new SmsSender();
  String address = someAddress();
  SmsMessage message = new SmsMessage(address, 'Hello flutter!');
  message.onStateChanged.listen((state) {
    if (state == SmsMessageState.Sent) {
      print("SMS is sent!");
    } else if (state == SmsMessageState.Delivered) {
      print("SMS is delivered!");

Some times it is useful to be notified of delivered messages regardless of the message. To do that you must subscribe to the onSmsDelivered of the SmsSender class instance:

void main() {
SmsSender sender = new SmsSender();
sender.onSmsDelivered.listen((SmsMessage message){
  print('${message.address} received your message.');

You can also send with another SimCard:

void main() {
SimCardsProvider provider = new SimCardsProvider();
SimCard card = await provider.getSimCards()[0];
SmsSender sender = new SmsSender();
SmsMessage message = new SmsMessage("address", "message");
sender.sendSMS(message, simCard: card);

Note: Using the onSmsDelivered from the SmsSender will only notify to listeners of messages that has been sent through SmsSender.send().

Receiving SMS #

If you want to be notified for incoming new messages you must subscribe to an instance of the SmsReceiver class:

import 'package:sms/sms.dart';

void main() {
  SmsReceiver receiver = new SmsReceiver();
  receiver.onSmsReceived.listen((SmsMessage msg) => print(msg.body));

Roadmap #

  • [x] SMS Receiver
  • [x] SMS Sender
  • [x] SMS Delivery
  • [x] SMS Query
  • [x] SMS Thread
  • [ ] MMS Receiver
  • [ ] MMS Sender
  • [ ] MMS Delivery
  • [ ] MMS Query
  • [ ] Multi Sim Card
  • [x] Contact
  • [x] Contact Photo (full size, thumbnail)
  • [x] User profile (basic info)

Contributors #

Designed and created by Imrul kayes

Contributions #

Any contribution is welcome.

[0.2.4] - 2018-09-30 #

  • Add fail state

[0.2.3] - 2018-09-29 #

  • Fix issue with SMS state handler

[0.2.2] - 2018-09-05 #

  • Update dart version

[0.2.1] - 2018-08-13 #

  • Fix issue with toString on error

[0.2.0] - 2018-08-09 #

  • Multi SIM card support

[0.1.6] - 2018-08-07 #

  • Fix permission error when sending SMS on Android O and above

[0.1.5] - 2018-08-06 #

  • Fix permission error on Android M and above

[0.1.4] - 2018-06-16 #

  • Error on contact lookup because of unknown size fixed

[0.1.3] - 2018-05-29 #

  • Error in Android 4.x because of missing permission 'READ_PROFILE' fixed
  • Updated Flutter environment sdk to ">=1.19.0 <2.0.0"
  • Example app code refactoring

[0.1.2] - 2018-05-26 #

  • Photo and thumbnail of a contact get loaded with the contact, no need to request them later.
  • Example app UI slightly enhanced.

[0.1.1] - 2018-05-14 #

  • Sms Delivery with Dart Streams and Event Channels
  • Fixed some minor errors
  • Fixed error on User Profile. The method 'getUserProfile()' will always return an instance of UserProfile even when no user profile configured in the device.
  • Fixed error in SmsThread.findContact when first message is a draft.

[0.1.0] - 2018-04-23 #

  • Sms Delivery

[0.0.10] - 2018-04-18 #

  • Automatically assign contact to created SmsThread
  • Small fix for 'date' and 'dateSent' of SmsMessage
  • Fixed error on multiple permissions requests
  • Get basic User Profile info.
  • Fix gradle build

[0.0.9] - 2018-03-15 #

  • backward compatibility for Contact (pull request #1 by joanpablo)

[0.0.8] - 2018-03-10 #

  • SmsReceiver creates all needed field
  • Add basic contact support

[0.0.7] - 2018-03-09 #

  • Small fix for SMS thread

[0.0.6] - 2018-03-09 #

  • Implementation of SMS thread

[0.0.5] - 2018-03-09 #

  • Support for dart < 2.0.0

[0.0.4] - 2018-03-09 #

  • Better query for SMS, now you can query by multiple kind instead of only one.

[0.0.3] - 2018-03-09 #

  • Better handling of permissions
  • Implementation of SmsQuery

[0.0.2] - 2018-03-08 #

  • Implementation of SmsSender

[0.0.1] - 2018-03-08 #

  • Implementation of SmsReceiver.


import 'package:flutter/widgets.dart';
import './app.dart';

void main() => runApp(new App());

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  sms: ^0.2.4

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:sms/sms.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 4, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/generated/i18n.dart.

Run flutter format to format lib/generated/i18n.dart.

Format lib/sms.dart.

Run flutter format to format lib/sms.dart.

Maintenance suggestions

Package is getting outdated. (-50.96 points)

The package was last published 78 weeks ago.

The description is too long. (-10 points)

Search engines display only the first part of the description. Try to keep the value of the description field in your package's pubspec.yaml file between 60 and 180 characters.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8