smshandler

Creator: coderz1093

Last updated:

0 purchases

smshandler Image
smshandler Images

Languages

Categories

Add to Cart

Description:

smshandler

smshandler #
Programmatic SMS Handler
Supports Android
This package developed for send sms programmatically from your flutter app.
It's in development mode and web, ios currently not supported
Read this documentation for configuring this package , an example is also included
Getting Started #
In your flutter project add the dependency

import 'package:smshandler/smshandler.dart';// import the package

static String number = "YOUR NUMBER"; // variable to store the number

static String msgData = "YOUR MESSAGE";// variable to store the message

static int simId = 0;// variable to provide the simId 0 for SIM1 and 1 for SIM2

Future<void> smsHandler() async {

String smsResponse;

try {
smsResponse = await Smshandler.sendYourSms(
number,
msgData,
simId
);
} on PlatformException {
smsResponse = 'SMS_FAILED';
}

print(smsResponse);

//call your function for send sms

}


copied to clipboard
##this plugin is in development mode ,stay tuned for future updates
##Complete example main.dart file
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:smshandler/smshandler.dart';

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

class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';

static TextEditingValue number;

static TextEditingValue msgData;

TextEditingController numberController =
TextEditingController.fromValue(number);

TextEditingController dataController =
TextEditingController.fromValue(msgData);

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

// Platform messages are asynchronous, so we initialize in an async method.
Future<void> smsHandler() async {
String smsResponse;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
smsResponse = await Smshandler.sendYourSms(
numberController.value.text,
dataController.value.text,
0
);
} on PlatformException {
smsResponse = 'SMS_FAILED';
}

print(smsResponse);

if (!mounted) return;
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 10.0,
right: 10.0,
top: 5.0,
bottom: 5.0,
),
child: TextField(
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
WhitelistingTextInputFormatter.digitsOnly
],
style: TextStyle(color: Colors.teal),
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0)),
),
controller: numberController,
),
),
Padding(
padding: const EdgeInsets.only(
left: 10.0,
right: 10.0,
top: 5.0,
bottom: 5.0,
),
child: TextField(
style: TextStyle(color: Colors.teal),
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0)),
),
controller: dataController,
),
),
RaisedButton(
child: Text("SendSMS"),
onPressed: () {
smsHandler();
},
),
],
),
),
),
);
}
}


copied to clipboard
##this also required permission to send sms add it manually
##in your app you can implement the code to request permission

<uses-permission android:name="android.permission.SEND_SMS" />

copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.