ensend_flutter library
The official Dart SDK for the Ensend multi-channel notification platform.
Quick start
import 'package:ensend_flutter/ensend_flutter.dart';
// Default (package:http)
final ensend = EnsendClient(secret: 'your_project_secret');
// With Dio
final ensend = EnsendClient.withDio(secret: 'your_project_secret');
// With debug logging
final ensend = EnsendClient(secret: 'sk_...', enableLogging: true);
final result = await ensend.send.sendMail(
SendMailRequest(
subject: 'Welcome!',
sender: EmailSender(address: 'hello@acme.com', name: 'Acme'),
recipients: [EmailRecipient(address: 'user@example.com', name: 'Alice')],
message: '<h1>Welcome, Alice!</h1>',
),
);
result.when(
onSuccess: (data) => print('Sent!'),
onError: (error) => print('Error: ${error.message}'),
);
Classes
- AudienceSourceConfig
- Configuration for an audience-group broadcast source.
- BroadcastBatchRequest
- Request payload for sending a subsequent batch to an existing broadcast.
- BroadcastMailRequest
- Request payload for initiating a new email broadcast to up to 250 recipients per batch.
- BroadcastOptions
- Optional settings for a broadcast email send.
- BroadcastSource
- A source of recipients for a broadcast send.
- ContentEmailAttachment
- An EmailAttachment whose content is provided as a base64-encoded string.
- CsvSourceConfig
- Configuration for a CSV file broadcast source.
- DioEnsendHttpClient
-
package:dio-backed transport for the Ensend API. - EmailAttachment
- A file attachment for an outgoing email.
- EmailRecipient
- A single email recipient.
- EmailSender
- The sender identity for an outgoing email.
- EmailTemplate
- References a saved Ensend template and optionally provides global personalization variables.
- EnsendClient
- The main entry point for the Ensend SDK.
- EnsendConfig
- Configuration for the Ensend API client.
- EnsendError
- Represents an error returned by the Ensend API.
- EnsendHttpAdapter
- Contract that all Ensend HTTP transport implementations must satisfy.
- EnsendHttpClient
-
package:http-backed transport for the Ensend API. - EnsendLogger
- Internal debug logger for the Ensend SDK.
-
EnsendResponse<
T> - The result envelope returned by every Ensend API call.
- EnsendSmtpConfig
- SMTP connection settings for sending email through Ensend's SMTP relay.
- SendApi
- Provides access to the Ensend Send API for transactional email and broadcast messaging.
- SendMailOptions
- Optional settings for a transactional email send.
- SendMailRequest
- Request payload for sending a transactional email to up to 10 recipients.
- UrlEmailAttachment
- An EmailAttachment whose content is fetched from a public URL at send time.
Enums
- ActionOnExisting
- Controls what happens when a recipient already exists in the target audience.
- SmtpEncryption
- The TLS mode used when connecting to Ensend's SMTP relay.
Extensions
-
JsonMapX
on Map<
String, dynamic> - Safe, coercing accessors for Map<String, dynamic> JSON payloads.
- JsonStringX on String
- JSON-parsing helpers on String.
- ObjectCoercionX on Object?
- Safe type-coercion helpers for any Object? value.
Exceptions / Errors
- EnsendException
- Base class for all exceptions thrown by the Ensend SDK.
- EnsendNetworkException
- Thrown when the HTTP request fails due to a network-level issue (no response received — e.g. no internet, DNS failure, connection refused).
- EnsendSerializationException
- Thrown when the SDK cannot parse the API response body.
- EnsendTimeoutException
- Thrown when the request exceeds the configured EnsendConfig.timeout.
- EnsendValidationException
- Thrown when required fields on a request model are invalid before the HTTP request is even made (e.g. too many recipients, missing message/template).