> ## Documentation Index
> Fetch the complete documentation index at: https://cloudinary.com/documentation/llms.txt
> Use this file to discover all available pages before exploring further.

# Dart SDK


[changelog-link]: https://github.com/cloudinary/cloudinary_dart/blob/master/api/CHANGELOG.md

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.
> **INFO**: :title=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][changelog-link] of the SDK to benefit from these security improvements.

## How would you like to learn?

{table:class=no-borders overview}Resource | Description 
--|--
[Dart quick start](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](https://github.com/cloudinary/cloudinary_dart) | Explore the source code and see the [CHANGELOG][changelog-link] for details on all new features and fixes from previous versions.
[Dart reference](https://cloudinary.com/documentation/sdks/dart/url-gen/index.html) | See all Dart transformation actions and qualifiers in the SDK reference documentation.
[Video tutorials](tutorial_screencasts) | Watch tutorials relevant to your use cases to learn how to use Cloudinary features. 

Other helpful resources...

This guide focuses on how to set up and implement popular Cloudinary capabilities using the Dart SDK, but it doesn't cover every feature or option. Check out these other resources to learn about additional concepts and functionality in general. 

{table:class=no-borders overview}Resource | Description 
--|--
[Developer kickstart](dev_kickstart) |A hands-on, step-by-step introduction to Cloudinary features.
[Glossary](cloudinary_glossary) | A helpful resource to understand Cloudinary-specific terminology.
[Guides](programmable_media_guides) | In depth guides to help you understand the many, varied capabilities provided by the product. 
[References](cloudinary_references) | Comprehensive references for all APIs, including Dart code examples.

## Install

To use this SDK, add Cloudinary as a [dependency in your pubspec.yaml file](https://dart.dev/tools/pub/pubspec).

```
dependencies:
  cloudinary_api: ^1.1.1
  cloudinary_url_gen: ^1.8.0
```

> **NOTE**: **This guide relates to the latest released version of the [Cloudinary Dart](https://github.com/cloudinary/cloudinary_dart) library, which includes the [cloudinary_url_gen](https://github.com/cloudinary/cloudinary_dart/tree/master/url_gen) and [cloudinary_api](https://github.com/cloudinary/cloudinary_dart/tree/master/api) packages.**

## Configure

Include Cloudinary's Dart classes in your code:

```dart
import 'package:cloudinary_api/cloudinary_api.dart';
import 'package:cloudinary_url_gen/cloudinary.dart';
```

### 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](image_upload_api_reference#upload)). You can find your configuration credentials in the [API Keys](https://console.cloudinary.com/app/settings/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**:
  
```dart
var cloudinary = Cloudinary.fromStringUrl('cloudinary://<your-api-key>:<your-api-secret>@<your-cloud-name>');
```

> **INFO**:
>
> * 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](cloudinary_sdks#configuration_parameters) if relevant.

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

```dart
cloudinary.config.urlConfig.secure = 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](cloudinary_sdks#analytics_config).

## 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&nbsp;example](#quick_example_file_upload)
* **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&nbsp;example](#quick_example_transform_and_optimize)

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.

### 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.

```dart
cloudinary.uploader().upload(
  File('dog.mp4'),
  params: UploadParams(
    resourceType: CloudinaryResourceType.video,
    publicId: 'my_dog',
    overwrite: true,
    notificationUrl: 'https://mysite.example.com/notify_endpoint'
  )
).then((response) => print(response));
```

> **Learn more about upload**:
>
> * Read the [Upload guide](upload_images) to learn more about customizing uploads, using upload presets and more.

> * See more examples of [image and video upload](dart_image_and_video_upload) using the Cloudinary Dart SDK.  

> * Explore the [Upload API reference](image_upload_api_reference) to see all available methods and options.

### Quick example: Transform and optimize

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

![sample transformation](https://res.cloudinary.com/demo/image/upload/c_thumb,g_face,h_150,w_150/r_20/e_sepia/l_cloudinary_icon/e_brightness:90/o_60/c_scale,w_50/fl_layer_apply,g_south_east,x_5,y_5/a_10/q_auto/front_face.png "disable_all_tab: true, with_url: false, frameworks: dart")

```dart
cloudinary.image('front_face.png').transformation(Transformation()
	.resize(Resize.thumbnail().width(150)
.height(150)
	.gravity(
	Gravity.focusOn(
	FocusOn.face()))
	)
	.roundCorners(RoundCorners.byRadius(20))
	.effect(Effect.sepia())
	.overlay(Overlay.source(
	Source.image("cloudinary_icon")
	.transformation(new Transformation()
	.adjust(Adjust.brightness().level(90))
	.adjust(Adjust.opacity(60))
	.resize(Resize.scale().width(50)))
	)
	.position(Position()
	.gravity(
	Gravity.compass(
	Compass.southEast()))
.offsetX(5)
.offsetY(5))
	)
	.rotate(Rotate.byAngle(10))
	.delivery(Delivery.quality(
	Quality.auto())));
```

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:

![sample transformation](https://res.cloudinary.com/demo/image/upload/c_thumb,g_face,h_150,w_150/r_20/e_sepia/l_cloudinary_icon/e_brightness:90/o_60/c_scale,w_50/fl_layer_apply,g_south_east,x_5,y_5/a_10/q_auto/front_face.png "disable_all_tab: true, with_code:false, with_image:false")

In a similar way, you can [transform a video](dart_media_transformations#apply_common_video_transformations).

> **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](dart_media_transformations#syntax_overview).

> **Learn more about transformations**:
>
> * Read the [Transform and customize assets](image_transformations) guide to learn about the different ways to transform your assets.

> * See examples of powerful [image and video](dart_media_transformations) transformations using Dart code, and see our [image transformations](image_transformations) and [video transformations](video_manipulation_and_delivery) docs.

> * See all possible transformations in the [Transformation URL API reference](transformation_reference).

> * See all Dart transformation actions and qualifiers in the [Dart reference](https://cloudinary.com/documentation/sdks/dart/url-gen/index.html).

> **READING**:
>
> * Learn more about [uploading images and videos](dart_image_and_video_upload) using the Dart SDK.    

> * See examples of powerful [image and video](dart_media_transformations) transformations using Dart code, and see our [image transformations](image_transformations) and [video transformation](video_manipulation_and_delivery) docs.   

> * Stay tuned for updates by following the [Release Notes](programmable_media_release_notes) and the [Cloudinary Blog](https://cloudinary.com/blog).

> * Take a look at our [iOS](ios_integration) and [Android](android_integration) SDKs as alternatives for mobile development with Cloudinary.
