contentstack 0.0.1 copy "contentstack: ^0.0.1" to clipboard
contentstack: ^0.0.1 copied to clipboard

outdated

Contentstack is a headless CMS with an API-first approach that puts content at the centre. It is designed to simplify the process of publication by separating code from content. In a world where conte [...]

example/example.md

Contentstack Examples #

Developer's Guide #

In order to integrate your Flutter app with Contentstack Dart SDK, follow the steps mentioned below.

Prerequisites #

To get started with Dart SDK, you will need the following:

Creating new project using android studio #

  1. In the IDE, click Create New Project from the Welcome window or File > New > Project from the main IDE window.
  2. Select Flutter in the menu, and click Next.
  3. Enter your desired Project name and Project location.
  4. If you might publish this app, set the company domain.
  5. Click Finish.

Creating new project using Visual Studio Code #

  1. Open the Command Palette (Ctrl+Shift+P (Cmd+Shift+P on macOS)).
  2. Select the Flutter: New Project command and press Enter.
  3. Enter your desired Project name.
  4. Select a Project location.

SDK Installation and Setup #

To integrate your Flutter project with Contentstack, install the pub dependency Use this package as a library

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

dependencies:
  contentstack: ^0.0.1

You can install packages from the command line: with Flutter:

$ flutter pub get

Import package #

Now in your dart or flutter code, you can use

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

Initialize SDK #

To initialize the SDK, specify application context, stack’s API Key, delivery token, and name of the environment where will publish your content, as shown in the snippet below:

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

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

Basic Queries #

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

Make call to get single entry by entry uid #

    final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
    final entry = stack.contentType('content_type_uid').entry(entryUid: 'entry_uid');
    await entry.fetch().then((response) {
      print(response.toString());
    }).catchError((error) {
      print(error.message.toString());
    });

Or, You can get generic objects as well

    final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
    final entry = stack.contentType('content_type_uid').entry(entryUid: 'entry_uid');
    await entry.fetch<EntryModel, Null>().then((response) {
      print(response.title);
    }).catchError((error) {
      print(error.message.toString());
    });

Get Multiple Entries #

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

    final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
    final query = stack.contentType('content_type_uid').entry().query();
    await query.find().then((response) {
      print(response.toString());
    }).catchError((error) {
      print(error.message.toString());
    });

Or, You can get List of generic objects

    final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
    final query = stack.contentType('content_type_uid').entry().query();
    await query.find<List<EntryModel>, EntryModel>().then((response) {
      print(response.toString());
    }).catchError((error) {
      print(error.message.toString());
    });

Make call to get single asset by asset uid #

      final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
      await stack.asset('asset_uid').fetch().then((response) {
        print(response.toString());
      }).catchError((error) {
        print(error.message.toString());
      });

Or, You can get generic objects as well

      final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
      await stack.asset('asset_uid').fetch<AssetModel, Null>().then((response) {
        print(response.toString());
      }).catchError((error) {
        print(error.message.toString());
      });

Make call to apply query on asset #

    final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
    final assetQuery = stack.assetQuery();
    assetQuery..includeDimension()..relativeUrls();
    await assetQuery.find().then((response) {
      print(response.toString());
    }).catchError((error) {
      print(error.message.toString());
    });

Or, You can get List of generic objects

    final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
    final assetQuery = stack.assetQuery();
    assetQuery..includeDimension()..relativeUrls();
    await assetQuery.find<List<AssetModel>, Null>().then((response) {
      print(response.toString());
    }).catchError((error) {
      print(error.message.toString());
    });
6
likes
0
pub points
10%
popularity

Publisher

verified publishercontentstack.com

Contentstack is a headless CMS with an API-first approach that puts content at the centre. It is designed to simplify the process of publication by separating code from content. In a world where content is consumed via countless channels and form factors across mobile, web and IoT. Contentstack reimagines content management by decoupling code from content. Business users manage content – no training or development required. Developers can create cross-platform apps and take advantage of a headless CMS that delivers content through APIs. With an architecture that’s extensible – but without the bloat of legacy CMS – Contentstack cuts down on infrastructure, maintenance, cost and complexity.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (LICENSE)

Dependencies

dartdoc, http, http_parser, json_annotation, logger, super_enum

More

Packages that depend on contentstack