flusmic 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 54

flusmic #

A prismic.io integration for Flutter

Getting Started #

Flusmic only need the prismic.io endpoint for fetching results.

final flusmic = Flusmic(prismicEndpoint: 'yourendpoint');

By the time, flusmic have only 4 types of fetching:

API #

For general prismic.io API information.

final api = await flusmic.getApi();

Root document #

The main document containing all the prismic.io documents.

final result = await flusmic.getRootDocument();

Fetching documents by type #

Fetching all the documents by a specific type using the slug.

final result = await flusmic.getDocumentsByType('typeSlug');

Fetching a document by id #

Fetching a specific document by the document id

final result = await flusmic.getDocumentById('documentId');

Handling results #

All the results (except for the API) returns a Result object. All the documents are stored in results property which, is a List of Documents.

Every document have a data property which is a JsonObject. You can get your json specific info parsing this object. We have pre-defined types to parse the basic prismic structure. Types like image, text, media, etc.

A (easy) way (we think) to use this is with BuiltValue:

https://github.com/google/built_value.dart

Example class:

abstract class Character implements Built<Character, CharacterBuilder> {
    Image get avatar;
    BuiltList<Text> get name;
}

With that class (and the remaining properties of BuiltValue), we only need to do a parsing for our specific type.

final character = Character.fromJson(json.encode(document.data.value));

We expect to have a better way to do this.

Types #

  • Dimension
  • Image
  • Language
  • Media
  • Span
  • Text

In the future #

  • [X] Slices.
  • [ ] Complete API properties.
  • [ ] Add remaining types.
  • [ ] Widgets?

[0.1.2] - Fix media type to be nullable.

[0.1.1] - Fix media type to be nullable.

[0.1.0] - Expose remaining types, slices added.

[0.0.2] - Expose types.

[0.0.1] - First release.

  • Prismic.io integration for flutter

example/main.dart

import 'package:flusmic/flusmic.dart';

main(List<String> args) async {
  final flusmic = Flusmic(prismicEndpoint: 'yourendpoint');

  ///Get API
  final api = await flusmic.getApi();
  print(api.toString());

  ///Get root document
  final root = await flusmic.getRootDocument();
  print(root.toString());

  ///Get document by type
  final documentsResult = await flusmic.getDocumentById('type');
  documentsResult.results.forEach((document) {
    print(document.data.toString());
  });

  ///Get document by id
  final documentResult = await flusmic.getDocumentById('id');
  print(documentResult.results.first.data.toString());
}

Use this package as a library

1. Depend on it

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


dependencies:
  flusmic: ^0.1.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:flusmic/flusmic.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
9
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]
54
Learn more about scoring.

We analyzed this package on Oct 18, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
built_collection ^4.2.2 4.2.2
built_value ^6.7.0 6.7.1
flutter 0.0.0
http ^0.12.0+2 0.12.0+2
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
fixnum 0.10.9
http_parser 3.1.3
matcher 0.12.5
meta 1.1.7
path 1.6.4
pedantic 1.8.0+1
quiver 2.0.5
sky_engine 0.0.99
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
build_runner ^1.6.1
built_value_generator ^6.7.0
flutter_test