flutter_send_sms
A Flutter plugin to send SMS messages using native Android and iOS capabilities.
A lightweight, fast, and platform-friendly Flutter plugin for sending SMS messages directly from your Flutter applications.
This package provides a simple Dart API with native implementations for Android and iOS.
Example
For a full working example, see the example/ directory in this repository.
# run the example
flutter run example/lib/main.dart
## Features
- Send SMS directly from Flutter
- Android & iOS support
- Minimal setup
- Easy API
- Handles runtime SMS permission on Android
---
## Platform Support
| Platform | Support | Notes |
|---------|---------|-------|
| Android | ✔️ | Requires SMS permission (`android.permission.SEND_SMS`) |
| iOS | ✔️ | Uses native message composer |
---
## Installation
Add the package to your `pubspec.yaml`:
```yaml
dependencies:
flutter_send_sms: ^1.0.0
Then run:
flutter pub get
Android Setup
1. Add required permission
Inside
android/app/src/main/AndroidManifest.xml
add:
<uses-permission android:name="android.permission.SEND_SMS" />
2. Request runtime permission
Android requires requesting SEND_SMS permission before sending SMS.
You may use packages such as permission_handler.
iOS Setup
iOS requires no additional configuration.
The plugin automatically opens the native SMS composer UI.
Usage
Quick Usage
import 'package:flutter_send_sms/flutter_send_sms.dart';
await FlutterSendSms.sendSms("+1234567890", "Hello from Flutter!");
Complete Example (with permissions)
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:flutter_send_sms/flutter_send_sms.dart';
class SmsPage extends StatefulWidget {
@override
_SmsPageState createState() => _SmsPageState();
}
class _SmsPageState extends State<SmsPage> {
final phoneController = TextEditingController();
final messageController = TextEditingController();
Future<void> _sendSms() async {
if (Platform.isAndroid) {
var status = await Permission.sms.status;
if (status.isDenied) {
await Permission.sms.request();
}
if (await Permission.sms.isGranted) {
await FlutterSendSms.sendSms(
phoneController.text.trim(),
messageController.text.trim(),
);
}
} else {
await FlutterSendSms.sendSms(
phoneController.text.trim(),
messageController.text.trim(),
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Send SMS")),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
TextField(
controller: phoneController,
decoration: InputDecoration(labelText: "Phone number"),
keyboardType: TextInputType.phone,
),
TextField(
controller: messageController,
decoration: InputDecoration(labelText: "Message"),
),
const SizedBox(height: 24),
ElevatedButton(
onPressed: _sendSms,
child: const Text("Send"),
),
],
),
),
);
}
}
API Reference
sendSms(String phone, String message)
Sends an SMS to the specified phone number.
| Parameter | Type | Description |
|---|---|---|
| phone | String | Destination phone number |
| message | String | Text message content |
Notes & Limitations
- Android: Requires runtime SMS permission.
- iOS: Opens the native message composer; user must manually press Send.
- Silent or automatic SMS sending is not supported due to OS security rules.
Contributions
Contributions, issues, and feature requests are welcome.
Feel free to open a pull request or create an issue in the repository.
License
MIT License.