buttercms_dart 0.1.0

buttercms_dart #

The official ButterCMS package for Flutter.

Documentation #

For a comprehensive list of examples, check out the API documentation.

Overview #

Every resource is accessed via your butter instance:

Butter butter = Butter('YOUR_API_KEY');

OR

var butter = Butter('YOUR_API_KEY');

Every resource method returns a Future:

// Get blog posts
butter.post.list({'page': '1', 'pageSize': '10'}).then((response) {
  print(response);
});

Pages #

  • page
    • retrieve(page_type, page_slug[, params])
      
    • list(page_type[, params])
      
// Get page
butter.page.retrieve('casestudy', 'acme-co').then((response) {
  print(response);
});

Content fields #

  • content
    • retrieve(keys)
      
// Get FAQ
butter.content.retrieve(["demo-key"]).then((resp) {
  print(resp);
});

Localization #

Setup locales in the ButterCMS dashboard and fetch localized content using the locale option:

// Get FAQ
butter.content.retrieve(["faq"], {'locale': 'es'}).then((resp) {
  print(resp);
});

Blog Engine #

post #

retrieve(slug[, params])

list([params])

search(query[, params])

category #

retrieve(slug[, params])

list([params])

tag #

retrieve(slug[, params])

list([params])

author #

retrieve(slug[, params])

list([params])

[0.1.0] - 22/06/2019

  • Initial release
  • Added Posts, Categories, Content, Pages, Posts, Tags.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:buttercms_dart/buttercms_dart.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'ButterCMS Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  // Initialising Butter
  Butter butter = Butter("YOUR_API_KEY");

  // Result of query (Usually, this result is parsed into respective model)
  String result = "";

  @override
  void initState() {
    super.initState();
    _getPosts().then((value) {
      setState(() {
        // Value passed as Response
        result = value.body;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: Text(result),
      ),
    );
  }

  // Get a specific post or list posts
  Future _getPosts() {
    return butter.post.list();
  }

  // Get data from one or more collections
  Future _getCollections() {
    return butter.content.retrieve(["YOUR_COLLECTION_NAME"]);
  }

  // Get one or more pages
  Future _getPages() {
    return butter.page.list("PAGE_TYPE_SLUG");
  }

  // Retrieve one or more authors
  Future _getAuthors() {
    return butter.author.list();
  }

  // Retrieve one or more tags
  Future _getTags() {
    return butter.tag.list();
  }

  // Retrieve one or more categories
  Future _getCategories() {
    return butter.category.list();
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  buttercms_dart: ^0.1.0

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:buttercms_dart/buttercms_dart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
11
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
55
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

15 out of 15 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
http ^0.12.0+2 0.12.0+2
Transitive dependencies
async 2.2.0
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
meta 1.1.6 1.1.7
path 1.6.2
pedantic 1.8.0+1
sky_engine 0.0.99
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test

Admin