Get Started with Dart SDK

This guide will help you get started with Contentstack Dart SDK to build Flutter apps powered by Contentstack.


Installation and Setup

To use the Contentstack Dart SDK with your existing project, perform the following steps:

Create a New Flutter Project in VS Code

  1. Open VS Code and select Extensions from the left navigation panel. 
  2. Then, in the Search Extensions in Marketplace search box, type Flutter. From the quick results, click on Flutter.
  3. From the Flutter details page, click on Install
  4. Press Ctrl + Shift + P on Windows and Cmd + Shift + P on macOS.
  5. Type flutter and select Flutter: New Project.
  6. If the Flutter SDK is not installed on your machine, it will ask you to Download SDK. Click on it and from the pop-up that opens, click on Open.
  7. It will take you the Flutter install page. Select as per your OS and the download will begin.
  8. Once it is installed, follow steps 4 and 5 and create a new Flutter project.

Create a New Project in Android Studio

  1. Open Android Studio and click on Configure
  2. Then, select Plugins. From the resulting screen, click on Flutter and click on Install.
  3. Click on Accept and then Yes to install the Dart plugin.
  4. Click on Restart when prompted.
  5. In the Android Studio IDE, click on Start a new Flutter project from the Welcome screen.
  6. Then, select Flutter Application in the menu, and click on Next.
  7. On the next screen, give your project a name, provide the Flutter SDK path (where you installed the Flutter SDK), and your project location.
  8. If you prefer publishing the app, set the company domain and click on Finish.

Initialize SDK

Contentstack offers two regions (the US and European) as data centers to store customers' account details and data. Both regions are independent of each other and therefore have a dedicated set of instructions to use SDKs offered by Contentstack.

To use SDKs for the European region, you will have to make certain changes in the configuration of the SDK, as detailed below, and the rest of the instructions remain the same.

Add this to your package's pubspec.yaml file:

  contentstack: ^0.0.1

To initialize the SDK, enter the stack’s API key, delivery token, and environment name where you will publish the content, as shown in the snippet below:

import 'package:contentstack/contentstack.dart' as contentstack;

final stack = contentstack.Stack(apiKey, deliveryToken, environment);

For Setting the European Region:

To set the European region, refer to the code below:

import 'package:contentstack/contentstack.dart' as contentstack;

final stack = contentstack.Stack(apiKey, deliveryToken, environment, region:;

Once you have initialized the SDK, you can query entries to fetch the required content.

Basic Queries

Contentstack SDKs let you interact with the Content Delivery APIs and retrieve content from Contentstack. They are read-only in nature. The SDKs fetch and deliver content from the nearest server via Fastly, our powerful and robust CDN.

Get a Single Entry

To retrieve a single entry from a content type, use the code snippet given below:

import 'package:contentstack/contentstack.dart' as contentstack;
final stack = contentstack.Stack(apiKey, deliveryToken, environment);
final entry = stack.contentType('content_type_uid').entry(entryUid: entryUid);
await entry.fetch().then((response) {
}).catchError((onError) {

Get Multiple Entries

To retrieve multiple entries of a particular content type, use the code snippet given below:

import 'package:contentstack/contentstack.dart' as contentstack;

final stack = contentstack.Stack(apiKey, deliveryToken, environment);
final query = stack.contentType('content_type_uid').entry().query();
await query.find().then((response){

These were examples of some of the basic queries of the SDK. For advanced queries, refer to Contentstack Dart SDK API Reference documentation.

Note: Currently, the Dart SDK does not support multiple content types referencing in a single query. For more information on how to query entries and assets, refer the Queries section of our Content Delivery API documentation.

Paginating Responses

In a single instance, the Get Multiple Entries query will retrieve only the first 100 items of the specified content type. You can paginate and retrieve the rest of the items in batches using the skip and limit parameters in subsequent requests. 

final stack = contentstack.Stack( "apiKey", "deliveryToken", "environment"); 
final query = stack.contentType("contentTypeUid").entry().query().skip(20).limit(20);
await query.find().then((response){


  • We have a URL size limitation of 8KB on API Requests that hit our CDN services. Any Request URL that goes above this size limit will receive the 400 - Bad request error response. Please make sure you limit the size of your API Requests.

Was this article helpful?

Thanks for your feedbackSmile-icon

More articles in "Use Dart SDK"

On This Page