flutter_ghost_content_api 0.0.3 copy "flutter_ghost_content_api: ^0.0.3" to clipboard
flutter_ghost_content_api: ^0.0.3 copied to clipboard

A Flutter wrapper around the Ghost Content API. Use this to access your blog posts and content in your Flutter app.

Flutter Ghost Content API #

A flutter wrapper around the Ghost Content API.

Blog post Explanation #

See this Ghost Content API blog post for a more in-depth explanation of the package.

Usage #

Before anything else, you will need to create a custom integration in your blog admin portal and make note of the Content API Key and URL.

Next, create a GhostContentAPIProvider at the root of your Flutter application:

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GhostContentAPIProvider(
      client: GhostContentAPIClient(
        version: 'v2',
        url: 'https://your-subdomain.ghost.io',
        contentAPIkey: 'your content api key',
      ),
      child: MaterialApp(
        title: 'Flutter Demo',       
        home: MyHomePage(),
      ),
    );
  }
}

Finally, you can use a FutureBuilder anywhere you would like to access your Ghost content:

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Flutter Ghost"),
      ),
      body: FutureBuilder(
        future: GhostContentAPIProvider.of(context).getPosts(),
        builder: (BuildContext context, AsyncSnapshot<PostsResponse> snapshot) {
          // Build your UI
        },
      ),
    );
  }
}

Alternatively, all calls through the Ghost Content API client returns a simple Future, so you can use any mechanism you need to for your app.

Example #

See the Flutter Ghost App for Learn Software for real-world usage.

Tests #

You can test this package by running the following commands:

  • flutter packages get
  • flutter test

Issues and Contributing #

See the GitLab project.

0
likes
20
pub points
0%
popularity

Publisher

unverified uploader

A Flutter wrapper around the Ghost Content API. Use this to access your blog posts and content in your Flutter app.

Homepage
Repository (GitLab)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter, http

More

Packages that depend on flutter_ghost_content_api