twilio_flutter 0.3.0 copy "twilio_flutter: ^0.3.0" to clipboard
twilio_flutter: ^0.3.0 copied to clipboard

A Package that helps with twilio API services. Features include sending SMS and WhatsApp messages among others.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Twilio_Flutter'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  late TwilioFlutter twilioFlutter;

  @override
  void initState() {
    twilioFlutter =
        TwilioFlutter(accountSid: "", authToken: "", twilioNumber: "");
    super.initState();
  }

  void sendSms() async {
    twilioFlutter.sendSMS(toNumber: '', messageBody: 'hello world');
  }

  void sendWhatsApp() {
    twilioFlutter.sendWhatsApp(toNumber: '', messageBody: 'hello world');
  }

  void getSms() async {
    var data = await twilioFlutter.getSmsList();
    print(data);

    await twilioFlutter.getSMS('');
  }

  void sendScheduledSms() async {
    await twilioFlutter.sendScheduledSms(
        toNumber: '',
        messageBody: 'hello world',
        sendAt: '2024-03-18T16:18:55Z');
  }

  void cancelScheduledSMS() async {
    await twilioFlutter.cancelScheduledSms(messageSid: '');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Text(
          'Click the button to send SMS.',
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: sendSms,
        tooltip: 'Send Sms',
        child: Icon(Icons.send),
      ),
    );
  }
}
102
likes
140
pub points
94%
popularity

Publisher

unverified uploader

A Package that helps with twilio API services. Features include sending SMS and WhatsApp messages among others.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

get_it, http, logging

More

Packages that depend on twilio_flutter