Read Inbox Messages - Flutter SMS Retriever

Last updated Mar 03, 2020

In this post we are going to learn how to read all Inbox Messages from Phone messages box in Flutter. For this we are going to use sms plugin. In the second part of this tutorial we will cover Search Inbox messages based on Number, messages

Let's get started


Read Phone Contacts in Flutter Application


Step 1: Create flutter application

Step 2: Add dependencies

add sms dependencies in pubspec.yaml file and run flutter pub get on terminal

    sdk: flutter
  sms: ^0.2.4


Step 3: Create dart file and add below code

class MyInbox extends StatefulWidget{
  State createState() {
    // TODO: implement createState
    return MyInboxState();


class MyInboxState extends State{
  SmsQuery query = new SmsQuery();
  List messages=new List();
 initState()  {
    // TODO: implement initState

  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text("SMS Inbox"),
      body: FutureBuilder(
        future: fetchSMS() ,
        builder: (context, snapshot)  {

        return ListView.separated(
            separatorBuilder: (context, index) => Divider(
            itemCount: messages.length,
            itemBuilder: (context,index){
          return Padding(
            padding: const EdgeInsets.all(8.0),
            child: ListTile(
              leading: Icon(Icons.markunread,color:,),
              title: Text(messages[index].address),
              subtitle: Text(messages[index].body,maxLines:2,style: TextStyle(),),

  async {
    messages = await query.getAllSms;

add  import 'package:sms/sms.dart';

To handle the SMS we need to create instance of SmsQuery

SmsQuery query = new SmsQuery();

in the above we are using the Future builder to read sms from Inbox by query.getAllSms method

This will return list of all messages from inbox.

Step 4: Update main dart file

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(

      home: MyInbox(),


Step 5: Run application


Add SMS Permissions in Manifest file





Article Contributed By :


Subscribe For Daily Updates

Flutter Questions
Android Questions