Dart SDK (BETA)
Last updated: Dec-28-2022
Overview
Cloudinary's Dart SDK provides simple, yet comprehensive image and video transformation, optimization, and delivery capabilities that you can implement using code that integrates seamlessly with your existing Dart application.
Key features
- Uses Cloudinary's new SDK action based syntax with enhanced code autocomplete.
- Build dynamic URLs for delivering images and videos.
- Actions and transformations are immutable, for easier and safer code reuse.
Get started
Install and configure the SDK in your project to get started.
Add the Dart SDK dependency
To use this SDK, add Cloudinary as a dependency in your pubspec.yaml file.
Add your Cloudinary configuration
The Cloudinary
class is the main entry point for using the library. Your cloud_name
is required to create an instance of this class. Your api_key
and api_secret
are also needed to perform secure API calls to Cloudinary (e.g., image and video uploads). Setting the configuration parameters can be done either programmatically using an appropriate constructor of the Cloudinary class or globally using an environment variable. You can find your configuration credentials in the Programmable Media Dashboard of the Cloudinary Console.
Here are two examples for setting configuration parameters in your Dart application:
Use
Cloudinary.fromStringUrl
and pass your API environment variable:var cloudinary = Cloudinary.fromStringUrl('cloudinary://<your-api-key>:<your-api-secret>@<your-cloud-name>');
Define optional configuration parameters by adding them to your configuration file. For example, set the
secure
optional configuration parameter totrue
in the configuration file namedcloudinary
:NoteThe examples in this SDK guide assume you've used thefromStringUrl
method of setting configuration parameters.Use
Cloudinary.fromCloudName
and pass yourcloudName
:CloudinaryContext.cloudinary = Cloudinary.fromCloudName(cloudName: '<your-cloud-name>');
Define optional configuration parameters by adding them to your configuration file. For example, set the
signUrl
optional configuration parameter totrue
:
Examples
Here's a simple example for generating a Cloudinary image URL, including a resize transformation, using the Dart SDK:
(cloudinary.image('sample.jpg') ..transformation(Transformation() ..resize(Resize.crop() ..width(100) ..height(150)))) .toString();
Here's a simple example for generating a Cloudinary video URL, including a resize transformation with boomerang and vignette effects, using the Dart SDK:
(cloudinary.video('ski_jump') ..transformation(Transformation() ..effect(Effect.boomerang()) ..effect(Effect.vignette(30)) ..resize(Resize.pad() ..height(360) ..width(480)))) .toString();
..generic()
method of the Dart SDK.For more information about the Dart SDK syntax, see Syntax overview.
- See all possible transformations in the Transformation URL API reference.
- See examples of powerful image and video transformations using Dart code
and see our image transformations and video transformations docs. - Stay tuned for updates, tips and tutorials in Product Updates and Blog Posts.
- Take a look at our iOS and Android SDKs as alternatives for mobile development with Cloudinary.