Programmable Media

Dart quick start

Last updated: Jun-04-2024

This quick start lets you get an end-to-end implementation up and running using the Dart SDK in 5 minutes or less.

1. Set up and configure the SDK

Install the package

Install the @cloudinary_url_gen package by adding Cloudinary as a dependency in your pubspec.yaml file.

Configure Cloudinary

Important
When writing your own applications, follow your organization's policy on storing secrets and don't expose your API secret.

In your main.dart file, configure your credentials using your API environment variable. Copy the API environment variable format from the API Keys page of the Cloudinary Console Settings. Replace <your_api_key> and <your_api_secret> with your actual values, while your cloud name is already correctly included in the format.

main.dart

2. Upload an image

Copy and paste this into main.dart:

main.dart (continued)

3. Transform and deliver the image

Displaying the full image URL based on the specified transformation parameters:

Copy and paste the following code, under the configuration code:

main.dart (continued)

Note
If you followed the steps to upload the docs/models asset, you might want to use that public ID instead of cld-sample. If you're using an image with a public ID other than cld-sample, make sure to update your code for the remainder of this quick start with the public ID of the image you're delivering.

4. Run your code

Run the code to see the transformed image.

Transformed image

View the completed code

This code is available on GitHub.

Ready to learn more?

✔️ Feedback sent!

Rate this page: