amplify-flutter-datastore-extension
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published
Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact

About The Project

This project is amplify plugin to generate Flutter Extensions for DataStore operations. This feature is automatically executed when run amplify codegen models.

NPM version codecov

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

First, install AWS Amplify CLI using npm (we assume you have pre-installed node.js).

npm install -g @aws-amplify/cli

Installation

  1. Install NPM packages
    npm install -g amplify-flutter-datastore-extension
  2. Enable this plugin
    amplify plugin add $(npm root -g)/amplify-flutter-datastore-extension

Usage

amplify/backend/api/{api_name}/schema.graphql containing the following:

type Todo @model {
  id: ID!
  name: String!
  description: String
}

Run the following command:

amplify codegen models

The plugin outputs DataStoreExtension.dart with the following contents:

import 'ModelProvider.dart';
import 'package:amplify_core/amplify_core.dart' as amplify_core;

/** This is an auto generated extension representing the Todo type in your schema. */
extension TodoExtension on amplify_core.DataStoreCategory {
  Future<Todo> getTodo(String id) {
    return query(
      Todo.classType,
      where: Todo.MODEL_IDENTIFIER.eq(TodoModelIdentifier(id: id)),
    )
    .then((list) => list.single);
  }

  Future<Todo?> getTodoOrNull(String id) {
    return query(
      Todo.classType,
      where: Todo.MODEL_IDENTIFIER.eq(TodoModelIdentifier(id: id)),
    )
    .then((list) => list.singleOrNull);
  }
}

You can call it as follows:

final id = "080f33bf-0362-4c7f-9dfa-de64fc231dca";
final todo = await Amplify.DataStore.getTodo(id);

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the Apache-2.0 License. See LICENSE for more information.

Contact

Masahiko MURAKAMI - @fossamagna

Project Link: https://github.com/fossamagna/amplify-flutter-datastore-extension

Package Sidebar

Install

npm i amplify-flutter-datastore-extension

Weekly Downloads

0

Version

0.2.3

License

Apache-2.0

Unpacked Size

70.3 kB

Total Files

60

Last publish

Collaborators

  • fossamagna