storyblok_client 1.0.1+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

Storyblok Client #

Client for accessing the Storyblok Headless CMS API through Dart.

Request response #

StoryblokResponse is returned when fetching stories. The object contains the original http response and the parsed stories. StoryblokResponse.stories are the parsed Story objects from Storyblok.

Story #

The Story object contains the same properties as the original Storyblok response. Use Story.content to access the story content.

See https://www.storyblok.com/docs/api/content-delivery#core-resources/stories/the-story-object for more information.

Retrieve one story #

Fetching an example story in the posts folder named one.

import 'package:storyblok_client/storyblok_client.dart';

void main() async {
  const token = '...';
  final storyblok = StoryblokClient(token: token, autoCacheInvalidation: true);

  final data = await storyblok.fetchOne(fullSlug: 'posts/one');
  final content = data.story.content;

  print(content['title']); // This is post one
}

Retrieve multiple stories #

Fetching multiple stories in the posts folder.

import 'package:storyblok_client/storyblok_client.dart';

void main() async {
  const token = '...';
  final storyblok = StoryblokClient(token: token, autoCacheInvalidation: true);

  final data = await storyblok.fetchMultiple(startsWith: 'posts');
  final stories = data.stories;

  for(final story in stories) {
    print(story.content['title']); // This is post one, This is post two etc..
  }
}

Filter stories #

Stories can be filtered by supplying multiple FilterQuery.<filter>() objects to the filterQueries array. Note that the operations is and in are FilterQuery.ensure and FilterQuery.contains due to reserved keywords.

Fetching stories by a specific user.

import 'package:storyblok_client/storyblok_client.dart';

void main() async {
  const token = '...';
  final storyblok = StoryblokClient(token: token, autoCacheInvalidation: true);

  final data = await storyblok.fetchMultiple(
    startsWith: 'posts',
    filterQueries: [
      FilterQuery.contains(
        attribute: 'user',
        value: 'John Doe',
      ),
    ],
  );
  final stories = data.stories;

  for (final story in stories) {
    print(story.content['user']); // John Doe
  }
}

Order stories #

Stories can be ordered by supplying an OrderBy object to the orderBy parameter.

Cache Invalidation #

The cache version can either be manually invalidated or automaticity invalided before each request. Control this behavios using the autoCacheInvalidation parameter.

When autoCacheInvalidation is set to false will the cache version not be auto invalidated before each request. To invalidate the cache version manually at appropriate stages in the project, use the invalidateCacheVersion() method.

1.0.1+1 #

  • Change internal structure of pacakge

1.0.1 #

  • Add documentation for all public members
  • Improve response with parsed data

1.0.0+3 #

  • Bugfix where token was not always being sent

1.0.0+2 #

  • Add example README.md

1.0.0+1 #

  • Update README.md

1.0.0 #

  • Initial package release

example/README.md

storyblok_client #

Demonstrates how to use the storyblok_client plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

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


dependencies:
  storyblok_client: ^1.0.1+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:storyblok_client/storyblok_client.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
40
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Jul 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
enum_to_string ^1.0.9 1.0.9
http ^0.12.0+4 0.12.1
intl ^0.16.1 0.16.1
meta ^1.1.8 1.2.2 1.3.0-nullsafety
recase ^3.0.0 3.0.0
Transitive dependencies
charcode 1.1.3
collection 1.14.13 1.15.0-nullsafety
http_parser 3.1.4
path 1.7.0
pedantic 1.9.2
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0 1.3.0-nullsafety
Dev dependencies
effective_dart ^1.2.1