A package written purely in Dart for accessing to Twilio features.

🎯 Insights

The main objective of dart_twilio package is to be friendly & flexible.

Feel free of using the package in the way that fits better to your developer experience.

⚠️ Warning

This package is on it's initial phase, we don't have a roadmap yet, but planning to support the most used features from Twilio.

Any contribution is more than welcome!

Index

📏 Requirements

SDK constraints

This package uses Dart >=3.10.1 <4.0.0

Twilio credentials

Make sure to have your Twilio Account SID and Auth Token ready, you can find them at the Twilio Console.

🚀 Getting started

Let's start by the beginning, add dart_twilio to your dependencies:

dart pub add dart_twilio

🧩 Features

🫆 Verify (v2)

To access to Twilio Verify API you first need to create an instance of TwilioVerifyService, you can do so by the following ways:

  1. Using Twilio shorthands
    final service = Twilio.verifyService(
        accountSid: '{your_acc_sid}',
        authToken: '{your_auth_token}',
        sid: '{your_verify_sid}',
    );
    
  2. Using a TwilioClient instance
    final client = Twilio.client(
        accountSid: '{your_acc_sid}', 
        authToken: '{your_auth_token}'
    );
    final service = client.verify('{your_verify_sid}')
    
  3. Creating a TwilioVerifyService instance
    final TwilioVerifyService service = .new(
        client: .new(
            accountSid: '{your_acc_sid}' 
            authToken: '{your_auth_token}'
        ),
        sid: '{your_verify_sid}',
    );
    

#sendCode

Sending a code generates a Verification object in Twilio platform.

Calling #sendCode returns a TwilioVerification which is a class containing all the information returned by the Twilio API.

  1. Send code via sms
    final TwilioVerification(:sid, :status) = await service.sendCode(.sms(to: 'to_value'));
    
  2. Send code via call
    final TwilioVerification(:sid, :status) = await service.sendCode(.call(to: 'to_value'));
    
  3. Send code via whatsapp
    final TwilioVerification(:sid, :status) = await service.sendCode(.whatsapp(to: 'to_value'));
    
  4. Send code via email
    final TwilioVerification(:sid, :status) = await service.sendCode(.email(to: 'to_value'));
    

#verify

Doing a code verification creates a VerificationCheck object in Twilio platform.

Calling #verify returns a TwilioVerificationCheck which is a class containing all the information returned by the Twilio API.

final TwilioVerificationCheck(:status) = await service.verify(
    .new(to: 'to_value', code: '1234')
);

🐛 Issues and feedback

Please feel free to create an issue in our issue tracker in case you face any.
Do you have feedback or a feature request? Let us know!

Libraries

dart_twilio
A package written purely in Dart for accessing to Twilio features