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:
dependencies:flutter:sdk:fluttersms:^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:
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:
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:
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:
voidmain() {
...
SmsSender sender = newSmsSender();
sender.onSmsDelivered.listen((SmsMessage message){
print('${message.address} received your message.');
}));
}