direct_sms 0.0.1 copy "direct_sms: ^0.0.1" to clipboard
direct_sms: ^0.0.1 copied to clipboard

A new Flutter plugin which help us to send sms with phone sms interaction (support only android).

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:direct_sms/direct_sms.dart';
import 'package:permission_handler/permission_handler.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  var directSms = DirectSms();

  @override
  void initState() {
    super.initState();
  }

  _sendSms({required String number, required String message}) async {
    final permission = Permission.sms.request();
    if (await permission.isGranted) {
      directSms.sendSms(message: message, phone: number);
    }
  }

  @override
  Widget build(BuildContext context) {
    var phoneController = TextEditingController();
    var messageController = TextEditingController();
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 16),
          child: Expanded(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                TextField(
                  controller: phoneController,
                  keyboardType: TextInputType.number,
                  decoration: const InputDecoration(
                    label: Text("Phone Number"),
                    border: OutlineInputBorder(),
                  ),
                ),
                const SizedBox(height: 16),
                TextField(
                  controller: messageController,
                  decoration: const InputDecoration(
                    label: Text("Message"),
                    border: OutlineInputBorder(),
                  ),
                ),
                const SizedBox(height: 16),
                ElevatedButton(
                    onPressed: () {
                      _sendSms(
                        message: messageController.text,
                        number: phoneController.text.trim(),
                      );
                    },
                    child: const Text("Send"))
              ],
            ),
          ),
        ),
      ),
    );
  }
}
3
likes
130
points
25
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter plugin which help us to send sms with phone sms interaction (support only android).

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on direct_sms