Contentstack - Dart Delivery SDK
Dart Delivery SDK for Contentstack
Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application front end, and Contentstack will take care of the rest. Read More.
Contentstack provides Dart Delivery SDK to build applications on top of Dart. Given below is the detailed guide and helpful resources to get started with our Dart Delivery SDK.
Prerequisite
This guide will help you get started with Contentstack Dart SDK to build Flutter apps powered by Contentstack.
SDK 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
- Open VS Code and select Extensions from the left navigation panel.
- Then, in the Search Extensions in Marketplace search box, type Flutter. From the quick results, click on Flutter.
- From the Flutter details page, click on Install.
- Press Ctrl + Shift + P on Windows and Cmd + Shift + P on macOS.
- Type flutter and select Flutter: New Project.
- 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.
- It will take you the Flutter install page. Select as per your OS and the download will begin.
- Once it is installed, follow steps 4 and 5 and create a new Flutter project.
Create a New Project in Android Studio
- Open Android Studio and click on Configure.
- Then, select Plugins. From the resulting screen, click on Flutter and click on Install.
- Click on Accept and then Yes to install the Dart plugin.
- Click on Restart when prompted.
- In the Android Studio IDE, click on Start a new Flutter project from the Welcome screen.
- Then, select Flutter Application in the menu, and click on Next.
- On the next screen, give your project a name, provide the Flutter SDK path (where you installed the Flutter SDK), and your project location.
- If you prefer publishing the app, set the company domain and click on Finish.
Add Dart Dependencies to Your Project
To use Contentstack's Dart SDK in your existing project, you need to add the following code within your pubspec.yaml file:
dependencies: contentstack: any
You can download the latest dependency version here.
Quickstart in 5 mins
Initializing your SDK
Contentstack offers six regions North America (NA), Europe (EU), Azure North America (AZURE_NA), Azure Europe (AZURE_EU), GCP North America (GCP_NA), and GCP Europe (GCP_EU) as data centers to store customers' account details and data. These 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 Europe, Azure NA, Azure EU region, GCP NA, or GCP EU 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:
dependencies: contentstack: ^any
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, region: contentstack.Region.<add_your_region>);
Note: By default, the SDK uses the North American region. Configuration changes are not required for North American region users.
Refer the below code if you want to use the Europe, Azure North America, Azure Europe, GCP North America region, or GCP Europe.
import 'package:contentstack/contentstack.dart' as contentstack; final stack = contentstack.Stack(apiKey, deliveryToken, environment, region: contentstack.Region.<add_your_region>);
Once you have initialized the SDK, you can query entries to fetch the required content.
For Setting the branch for Europe, Azure North America, Azure Europe, GCP North America, or GCP Europe refer the code below:
For Setting Branch
import 'package:contentstack/contentstack.dart' as contentstack; final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment', branch: 'branch');
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 contentstack stack = contentstack.Stack(api_key='api_key', delivery_token='delivery_token', environment='environment') contentType = stack.content_type("content_type_uid") entry = content_type.entry("entry_uid") response = entry.fetch()
Get Multiple Entries
To retrieve multiple entries of a particular content type, use the code snippet given below:
import contentstack stack = contentstack.Stack(api_key='api_key', delivery_token='delivery_token', environment='environment') query = stack.content_type("content_type_uid").query() response = query.find()
Pagination
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){ print(response); }).catchError((onError){ print(onError.message); });
Stack
Stack an instance of ContentType, asset, assetQuery, and sync
syncToken
In this API request, you need to provide the sync_token that you received in the last complete sync process. If there are more than 100 records, you will get a pagination_token instead
Name | Type | Description |
---|---|---|
syncToken | String | sync token fetches only the content that was added after your last sync |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); var response = stack.syncToken("syncToken")
sync
The Sync API takes care of syncing your Contentstack data with your app and ensures that the data is always up-to-date by providing delta updates.
Name | Type | Description |
---|---|---|
contentTypeUid | String | content type UID. e.g., products This retrieves published entries of specified content type. |
fromDate | String | Enter the start date. e.g., 2018-08-14T00:00:00.000Z This retrieves published entries starting from a specific date |
locale | String | Enter locale code. e.g., en-us This retrieves published entries of the specific locale |
publishType | PublishType | Applicable values are:
If you do not specify any value, it will bring all published entries and published assets. |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); var response = stack.sync("contentTypeUid", "fromDate", "locale", PublishType.Entry_Published)
setHost
Adds host for the request
Name | Type | Description |
---|---|---|
host (required) | String | The host for the API url |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); stack.setHost("host") </span>
setHeader
adds header using header key and value
Name | Type | Description |
---|---|---|
key (required) | String | The header key |
value (required) | String | the header value |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); stack.setHeader("headerKey", "headerValue") </span>
removeHeader
Remove header using headerKey
Name | Type | Description |
---|---|---|
headerKey (required) | String | The header key |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); stack.removeHeader("headerKey") </span>
paginationToken
Name | Type | Description |
---|---|---|
paginationToken (required) | String | The pagination token |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); var response = stack.paginationToken("paginationToken") </span>
imageTransform
The Image Delivery API is used to retrieve, manipulate and/or convert image files of your Contentstack account and deliver it to your web or mobile properties.
Name | Type | Description |
---|---|---|
imageUrl (required) | String | Base Image Url of the image you want to manipulate |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); var image = stack. </span>
getContentTypes
ContentType accepts contentTypeId in as the parameter
Name | Type | Description |
---|---|---|
queryParams (required) | Map | ContentType accepts query params as parameter |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); var contentType = stack.
contentType
ContentType accepts contentTypeId in as the parameter
Name | Type | Description |
---|---|---|
contentTypeId (required) | String | ContentType accepts contentTypeId as the parameter |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); var contentType = stack.contentType("contentTypeId")
assetQuery
It also returns the content of each asset in JSON format.
Name | Type | Description |
---|---|---|
uid (required) | String | Asset uid |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); var assets = stack.assetQuery()
asset
This call fetches the latest version of a specific. asset of a particular stack.
Name | Type | Description |
---|---|---|
uid (required) | String | Asset uid |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); var asset = stack.asset("uid")
getLivePreview
Live preview of the stack
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); var preview = stack.getLivePreview
host
host of the stack
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); var host = stack.host
environment
environment of the stack
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); var environment = stack.environment
endpoint
endpoint for the api
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); var endpoint = stack.endpoint
deliveryToken
delivery token for the stack
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); var deliveryToken = stack.deliveryToken
stack
an instance of the stack
Name | Type | Description |
---|---|---|
apiKey (required) | String | apiKey of the stack |
deliveryToken (required) | String | Delivery Token for the stack |
environment (required) | String | Environment of the stack |
apiVersion | String | apiVersion is version of the API Default: v3 |
region | Region | DB region for your stack. You can choose from six regions namely, NA, EU, Azure NA, Azure EU, GCP NA, and GCP EU. |
host | String | host of the api |
livePreview | dict | live preview for the stack |
client | BaseClient | Client to make API request |
import Contentstack final stack = contentstack.Stack(apiKey, deliveryToken, environment);
apiKey
apiKey of for the stack
import Contentstack final stack = contentstack.Stack(" ", " ", " "); var apiKey = stack.apiKey
Asset
The asset provides asset methods
version
Specify the version number of the asset that you wish to retrieve. If the version is not specified, the details of the latest version will be retrieved..
import contentstack; final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final asset = stack.asset("assetUid")..version();
includeFallback
Retrieve the published content of the fallback locale if an entry is not localized in specified locale.
import contentstack; final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final asset = stack.asset("assetUid")..includeFallback();
includeDimension
include the dimensions (height and width) of the image in the response. Supported image types: JPG, GIF, PNG, WebP, BMP, TIFF, SVG, and PSD.
import contentstack; final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final asset = stack.asset("assetUid")..includeDimension();
environment
To fetch the content based on specific environment
Name | Type | Description |
---|---|---|
environment (required) | String | The environment |
import contentstack; final stack = contentstack.Stack("apiKey", "deliveryToken", "environment");
AssetQuery
The AssetQuery provides query on assets
includeBranch
Included branch in the response.
import contentstack
final var stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
final asset = stack.assetQuery()..includeBranch();
version
Specify the version number of the asset that you wish to retrieve.
import contentstack
final var stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
final asset = stack.assetQuery()..version(3);
relativeUrls
includes the relative URLs of the assets in the response
import contentstack
final var stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');final asset = stack.assetQuery()..relativeUrls();
includeFallback
Retrieve the published content of the fallback locale if an entry is not localized in specified locale.
import contentstack
final var stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
final asset = stack.assetQuery()..includeFallback();
includeDimension
include the dimensions (height and width) of the image in the response.
import contentstack
final var stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');final asset = stack.assetQuery()..includeCount();
includeCount
To retrieve the count of entries.
import contentstack
var stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');final asset = stack.assetQuery()..includeCount();
environment
Enter the name of the [environment] if you wish to retrieve the assets published in a particular environment.
Name | Type | Description |
---|---|---|
environment (required) | String | The Environment |
import Contentstack final stack = final contentType = stack.contentType(“content_type_uid”); final asset = stack.assetQuery()..environment();
ImageTransformation
ImageTransformation provides Query on image URL
brightness
The brightness parameter allows you to increase or decrease the intensity with which an image reflects or radiates perceived ligh.
Name | Type | Description |
---|---|---|
brightness (required) | int | you can also define brightness using any decimal number |
import contentstack; final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final imageTransformation = stack.imageTransform(imageUrl).brightness(3)
blur
The blur parameter allows you to decrease the focus and clarity of a given image. To specify the extent to which you need to increase the blurriness of an image, use any decimal number (float) between 1 and 1000.
Name | Type | Description |
---|---|---|
blur (required) | int | It can accept hexadecimal, combination of (Red, Blue, Green) and (Red, Blue, Green, Alpha) |
import contentstack; final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final imageTransformation = stack.imageTransform(imageUrl).bgBolor('Red')
bgColor
he bg-color function lets you set a backgroud color for the given image. This is useful when applying padding or for replacing the transparent pixels of an image..
Name | Type | Description |
---|---|---|
bgColor | String | It can accept hexadecimal, combination of (Red, Blue, Green) and (Red, Blue, Green, Alpha) |
import contentstack; final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final imageTransformation = stack.imageTransform(imageUrl).bgBolor('Red')
auto
Specify the version number of the asset that you wish to retrieve. If the version is not specified, the details of the latest version will be retrieved.
Name | Type | Description |
---|---|---|
auto | String | auto parameter is set to webp |
format | String | The format |
import contentstack; final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final imageTransformation = stack.imageTransform(imageUrl).auto(auto: 'webp', format: 'pjpg')
ContentType
Content provides an instance of and entry and query
fetch
This call returns information of a specific content type. It returns the content type schema, but does not include its entries.
Name | Type | Description |
---|---|---|
queryParams | Map<String, dynamic> | The Query Parameters |
import Contentstack final stack = final contentType = stack.contentType(“content_type_uid”); final Map queryParameter = {"key": "value"}; queryParameter[“include_snippet_schema”] = true; queryParameter[“limit”] = 3; final response = contentType.fetch(queryParameter);
entry
This function provide option to get single entry as well as all the entries
Name | Type | Description |
---|---|---|
entry_uid | String | the entry uid |
import Contentstack final stack = contentstack.Stack('apiKey','deliveryToken','environment'); final contentType = stack.contentType(); final entry = contentType.entry(entryUid: 'entry_uid');
find
This call returns comprehensive information of all the content types available in a particular stack in your account.
Name | Type | Description |
---|---|---|
queryParam | Map<String, String> | Query parameters |
import Contentstack final stack = contentstack.Stack('apiKey','deliveryToken','environment'); final contentType = stack.contentType().query(); var response = contentType.find();
includeGlobalField
This method includes the Global field's schema along with the content type schema.
import Contentstack final stack = contentstack.Stack('apiKey','deliveryToken','environment'); final contentType = stack.contentType().query(); contentType.includeGlobalField()
includeCount
This method includes the includeCount method facilitate to find the total count of content types available in your stack.
import Contentstack final stack = contentstack.stack("apiKey", "delieveryToken", "environment") final entry = stack.contentType("contentType").entry("uid"); entry.includeCount();
Entry
The Entry provides data based on entry uid
only
Specifies an array of only keys in BASE object that would be included in the response.
Name | Type | Description |
---|---|---|
fieldUid (required) | List<String> | The field uid is list of string |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final entry = stack.contentType('contentType').entry("uid"); entry.only(fieldUid);
locale
This method also includes the content type UIDs of the referenced entries returned in the response.
Name | Type | Description |
---|---|---|
locale (required) | String | The locale code |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final entry = stack.contentType('contentType').entry("uid"); entry.locale('en-eu');
includeReferenceContentTypeUID
This method also includes the content type UIDs of the referenced entries returned in the response.
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final entry = stack.contentType('contentType').entry("uid"); entry.includeReferenceContentTypeUID();
includeReference
Include Reference: When you fetch an entry of a content type that has a reference field, by default, the content of the referred entry is not fetched. It only fetches the UID of the referred entry, along with the content of the specified entry.
Name | Type | Description |
---|---|---|
referenceFieldUid (required) | String | referenceFieldUid Key who has reference to some other class object |
includeReferenceField | Include | includeReference provides three options, none, only and except |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final entry = stack.contentType('contentType').entry("uid"); entry.includeReference("referenceFieldUid", IncludeReference.none(fieldUidList: null));
includeBranch
Includes branch in the response
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final entry = stack.contentType('contentType').entry("uid"); entry.includeBranch();
includeEmbeddedItems
Include Embedded Objects (Entries and Assets) along with entry/entries details
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final entry = stack.contentType('contentType').entry("uid"); entry.includeEmbeddedItems();
includeFallback
Retrieve the published content of the fallback locale if an entry is not localized in specified locale.
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final entry = stack.contentType('contentType').entry("uid"); entry.includeFallback();
includeContentType
Include Content Type of all returned objects along with objects themselves
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final entry = stack.contentType('contentType').entry("uid"); entry.includeContentType();
except
Specifies list of field uids that would be excluded from the response.
Name | Type | Description |
---|---|---|
fieldUid (required) | List<String> | field uid which get excluded from the response |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final entry = stack.contentType('contentType').entry("uid"); entry.except(fieldUid); //
addParam
This method adds key and value to an Entry.
Name | Type | Description |
---|---|---|
key (required) | String | The key as string which needs to be added to an Entry |
value (required) | String | The value as string which needs to be added to an Entry |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final entry = stack.contentType('contentType').entry("uid"); entry.addParam(key, value);
Query
The Query provides entries based on queries applied
where
Get entries containing the field values matching the condition in the query.
Name | Type | Description |
---|---|---|
fieldUid (required) | String | The field uid |
queryOperation (required) | QueryOperation | The QueryOperation |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final query = stack.contentType('contentType').entry().query(); query.where("fieldUid", QueryOperation);
skip
The number of objects to skip before returning any.
Name | Type | Description |
---|---|---|
skipCount (required) | Int | No of objects to skip from returned objects |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final query = stack.contentType('contentType').entry().query(); query.skip(4);
query
Add a custom query against specified key.
Name | Type | Description |
---|---|---|
key (required) | String | key for the query |
value (required) | String | value for the query |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final query = stack.contentType('contentType').entry().query(); query.addQuery("param_key", "param_value");
param
This method adds key and value to an Entry.
Name | Type | Description |
---|---|---|
key (required) | String | key by which you can sort the results in descending order |
value (required) | String | value of the param against the key |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final query = stack.contentType('contentType').entry().query(); query.param("Key", "Value");
orderByDescending
Sort the results in descending order with the given key.
Name | Type | Description |
---|---|---|
key (required) | String | key by which you can sort the results in descending order |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final query = stack.contentType('contentType').entry().query(); query.orderByDescending("descendingKey");
orderByAscending
sort the results in ascending order with the given key.
Name | Type | Description |
---|---|---|
key (required) | String | key by which you can sort the results in ascending order |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final query = stack.contentType('contentType').entry().query(); query.ascending("ascKey");
limit
A limit on the number of objects to return.
Name | Type | Description |
---|---|---|
limitCount (required) | int | the count you want to limit your response |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final query = stack.contentType('contentType').entry().query(); query.limit(2);
addQuery
Add a custom query against specified key. parameters The key and value pair that will be added to the Query
Name | Type | Description |
---|---|---|
parameters (required) | Map | comma-separated string value |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final query = stack.contentType('contentType').entry().query(); query.addParams("keyword1", "keyword2", "keyword3");
addParams
This method adds key and value to the Query as Query parameter.
Name | Type | Description |
---|---|---|
key (required) | String | Key of the query parameter |
value (required) | String | Value of the Query parameter against the key |
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final query = stack.contentType('contentType').entry().query(); query.addParam("Key", "Value")
includeBranch
includes branch in the response
import Contentstack final stack = contentstack.stack(apiKey, delieveryToken, environment) final query = stack.contentType('room').entry().query(); query.includeBranch()
whereReference
Get entries having values based on referenced fields This query retrieves all entries that satisfy the query conditions made on referenced fields.
Name | Type | Description |
---|---|---|
referenceUid (required) | String | The referenced uid |
reference (required) | QueryReference | It accepts Enum type QueryReference.include() OR QueryReference.NotInclude() and it accepts instance of Query |
import Contentstack final query = stack.contentType('room').entry().query(); query.referenceSearch('fieldUid', QueryReference.include(query: query)); await query.find().then((response){ print(response); });
setHeader
adds header to the request
Name | Type | Description |
---|---|---|
key (required) | String | key of the header |
value (required) | String | value of the header against the key |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final query = stack.contentType('contentTypeUid').entry().query(); query.setHeader("key", "value")
removeHeader
Removed header from the request by key
Name | Type | Description |
---|---|---|
key (required) | String | key of the header |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final query = stack.contentType('contentTypeUid').entry().query(); query.removeHeader("key")
operator
entries that satisfy at least one of the given conditions provided
Name | Type | Description |
---|---|---|
listOfQuery (required) | QueryOperator.and(queryObjects: List<Query>) | QueryOperator using and/or functions that accepts list of queries |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment");final query = stack.contentType('contentTypeUid').entry().query();query.operator(QueryOperator.OR); final stackInstance1 = Credential.stack(); final queryBase1 = stackInstance1.contentType('room').entry().query(); queryBase1.where('title', QueryOperation.equals(value: 'Room 13')); final stackInstance2 = Credential.stack(); final queryBase2 = stackInstance2.contentType('room').entry().query(); queryBase2.where('attendee', QueryOperation.equals(value: 20)); final List listOfQuery = [queryBase1, queryBase2]; query.operator(QueryOperator.or(queryObjects: listOfQuery)); await query.find().then((response) { print(response.toString()); }).catchError((onError){ print(onError); });
only
provides data that contains only mentinoed keywords
Name | Type | Description |
---|---|---|
fieldUid (required) | List<String> | Array of the only reference keys to be included in response |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final query = stack.contentType('contentTypeUid').entry().query(); query.only(fieldUid);
locale
[locale] is the code of the language in which the entries need to be included.
Name | Type | Description |
---|---|---|
locale (required) | String | [locale] is code of the language of which the entries needs to be included. |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final query = stack.contentType('contentTypeUid').entry().query(); query.locale("locale_code");
includeReferenceContentTypeUID
This method also includes the content type UIDs of the referenced entries returned in the response
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final query = stack.contentType('contentTypeUid').entry().query(); query.includeReferenceContentTypeUID();
includeReference
When you fetch an entry of a content type that has a reference field, by default, the content of the referred entry is not fetched. It only fetches the UID of the referred entry, along with the content of the specified entry
Name | Type | Description |
---|---|---|
referenceFieldUid (required) | String | Key who has reference to some other class object |
includeReferenceField | IncludeReference | provides three options, none, only and except i.e accepts list of fieldUid |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final query = stack.contentType('contentTypeUid').entry().query(); query.includeReference("referenceFieldUid", IncludeReference.except(fieldUidList: fieldUid));;
includeEmbeddedItems
Include Embedded Objects (Entries and Assets) along with entry/entries details
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final query = stack.contentType('contentTypeUid').entry().query(); query.includeEmbeddedItems();
includeFallback
Retrieve the published content of the fallback locale if an entry is not localized in specified locale.
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final query = stack.contentType('contentTypeUid').entry().query(); query.includeFallback();
includeContentType
Include Content Type of all returned objects along with objects
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final query = stack.contentType('contentTypeUid').entry().query(); query.includeContentType();
except
Specifies list of field uids that would be excluded from the response. [fieldUid] field uid which get excluded from the response.
Name | Type | Description |
---|---|---|
fieldUid (required) | List<String> | fieldUid is String type of List |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final query = stack.contentType('contentTypeUid').entry().query(); query.except(fieldUid);
addParam
This method adds key and value to an Entry.
Name | Type | Description |
---|---|---|
key (required) | String | key of the parameter |
value (required) | String | value of the param against the key |
import Contentstack final stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); final query = stack.contentType('contentTypeUid').entry().query(); entry.addParam("key", "value");