Image & Video APIs

Dart SDK

Last updated: Dec-01-2025

The Cloudinary 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.

SDK security upgrade, June 2025
We recently released an enhanced security version of this SDK that improves the validation and handling of input parameters. We recommend upgrading to the latest version of the SDK to benefit from these security improvements.

How would you like to learn?

Resource Description
Dart quick start Get up and running in five minutes with a walk through of installation, configuration, upload, management and transformations.
Cloudinary Dart SDK GitHub repo Explore the source code and see the CHANGELOG for details on all new features and fixes from previous versions.
Dart reference See all Dart transformation actions and qualifiers in the SDK reference documentation.

Install

To use this SDK, add Cloudinary as a dependency in your pubspec.yaml file.

Note
This guide relates to the latest released version of the Cloudinary Dart library, which includes the cloudinary_url_gen and cloudinary_api packages.

Configure

Include Cloudinary's Dart classes in your code:

Set required configuration parameters

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). You can find your configuration credentials in the API Keys page of the Cloudinary Console Settings.

To set configuration parameters in your Dart application, use Cloudinary.fromStringUrl and pass your API environment variable:

Important
  • When writing your own applications, follow your organization's policy on storing secrets and don't expose your API secret.
  • If you use a method that involves writing your environment variable to a file, exclude the file from your version control system, so as not to expose it publicly.

Tip
To generate transformation URLs, you only need to configure the cloud name. The API key and API secret aren't required for URL generation.

Set additional configuration parameters

In addition to the required configuration parameters, you can define a number of optional configuration parameters if relevant.

For example, set the secure optional configuration parameter to true:

Note
By default, URLs generated with this SDK include an appended SDK-usage query parameter. Cloudinary tracks aggregated data from this parameter to improve future SDK versions. We don't collect any individual data. If needed, you can disable the urlAnalytics configuration option. Learn more.

Use

Once you've installed and configured the Dart SDK, you can use it for:

  • Uploading files to your product environment: You can upload any files, not only images and videos, set your own naming conventions and overwrite policies, moderate and tag your assets on upload, and much more. See example
  • Transforming and optimizing images and videos: Keeping your original assets intact in your product environment, you can deliver different versions of your media - different sizes, formats, with effects and overlays, customized for your needs. See example

Quick example: File upload

The following Dart code uploads the dog.mp4 video using the public_id, my_dog. The video overwrites the existing my_dog video if it exists. When the video upload finishes, the specified notification URL receives details about the uploaded media asset.

Learn more about upload

Quick example: Transform and optimize

Take a look at the following transformation code and the image it delivers:

sample transformation

This relatively simple code performs all of the following on the original front_face.jpg image before delivering it:

  • Crop to a 150x150 thumbnail using face-detection gravity to automatically determine the location for the crop
  • Round the corners with a 20 pixel radius
  • Apply a sepia effect
  • Overlay the Cloudinary logo on the southeast corner of the image (with a slight offset). Scale the logo overlay down to a 50 pixel width, with increased brightness and partial transparency (opacity = 60%).
  • Rotate the resulting image (including the overlay) by 10 degrees
  • Optimize the image to reduce the size of the image without impacting visual quality.
  • Convert and deliver the image in PNG format (the originally uploaded image was a JPG)

And here's the URL that's automatically generated from the above code:

In a similar way, you can transform a video.

Note
Most transformations can be passed as parameters using Cloudinary's new action based syntax with enhanced code autocomplete. Transformations that aren't yet supported for the new syntax can still be implemented by passing them directly as strings via the ..addTransformation() method of the Dart SDK.

For more information about the Dart SDK syntax, see Syntax overview.

Learn more about transformations

Related topics

✔️ Feedback sent!

Rate this page: