sms_reader 0.1.2 copy "sms_reader: ^0.1.2" to clipboard
sms_reader: ^0.1.2 copied to clipboard

PlatformAndroid

A Flutter plugin to read SMS messages from Android devices, with detailed fields and runtime permission handling.

example/lib/main.dart

// ignore_for_file: library_private_types_in_public_api

import 'package:flutter/material.dart';
import 'package:sms_reader/sms_reader.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) => MaterialApp(home: SmsPage());
}

class SmsPage extends StatefulWidget {
  const SmsPage({super.key});

  @override
  _SmsPageState createState() => _SmsPageState();
}

class _SmsPageState extends State<SmsPage> {
  List<Message> messages = [];

  void loadSms() async {
    try {
      List<Message> messages = await SmsReader.getInboxSms();
      setState(() {
        this.messages = messages;
      });
    } catch (e) {
      print(e);
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('SMS Reader Example')),
      body: Column(
        children: [
          ElevatedButton(onPressed: loadSms, child: const Text('Load SMS')),
          Expanded(
            child: ListView.builder(
              itemCount: messages.length,
              itemBuilder: (_, i) => ListTile(
                title: Text(messages[i].address),
                subtitle: Text(messages[i].body),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
3
likes
150
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to read SMS messages from Android devices, with detailed fields and runtime permission handling.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on sms_reader

Packages that implement sms_reader