Programmable Media

Dart SDK

Last updated: Jun-04-2024

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.

The Dart SDK allows you to transform and deliver assets that are already in your Cloudinary repository. See Dart image and video upload to upload using the upload method of Cloudinary's Upload API.

Tip
In this guide you'll learn how to get started with the Dart SDK, but if you are not familiar with Cloudinary, we advise reading How to integrate Cloudinary first for a high-level overview of integrating Cloudinary into your code, and an introduction to the main concepts.

Related topics
This guide relates to the latest released version of the Cloudinary Dart library.

On this page:

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 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:

Define optional configuration parameters by adding them to your configuration file. For example, set the secure optional configuration parameter to true in the configuration file named cloudinary:

Examples

Here's a simple example for generating a Cloudinary image URL, including a resize transformation, using the Dart SDK:

Simple example

Here's a simple example for generating a Cloudinary video URL, including a resize transformation with boomerang and vignette effects, using the Dart SDK:

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

✔️ Feedback sent!

Rate this page: