Skip to content

[RFC]: Amplify Flutter #5

Closed
Closed
@Amplifiyer

Description

This issue is a Request For Comments (RFC). It is intended to elicit community feedback regarding support for Amplify library in Flutter platform. Please feel free to post comments or questions here.

Purpose

Currently there is no official support for integrating with Amplify libraries in Flutter apps. This RFC goes over a proposal to build and release Amplify libraries in pub.dev that can be used in cross platform flutter apps.

Goals

  • Amplify iOS and Amplify Android parity: We would like to support all the use cases supported by these platforms in Amplify Flutter, including the following categories
    • Analytics
    • API (Rest/GraphQL)
    • Authentication (including Hosted UI)
    • DataStore
    • Predictions
    • Storage
    • Hub Events (Listening to the Amplify events)
  • Consistency with other platforms: Keep the public interface and API behavior consistent with Amplify iOS and Android libraries.
  • Pluggability: Customers should be able to implement/add their own cloud provider plugins for a given category.
  • UI Components: Provide a set of UI components intended to help developers leverage Amplify categories such as API, Auth, Storage etc.

Definitions

Categories: Use case driven abstractions such as Auth, Analytics, Storage that provide easy to use interfaces.
Providers: A cloud provider or a service provider such as Cognito, Auth0 in Auth category; Kinesis, Pinpoint and Firehose in Analytics Category; Rekognition, Textract in Predictions Category.
Plugins: Also called Amplify Plugins, bind providers to categories. They implement provider functionalities adhering to categories easy-to-use interfaces. Amplify Plugins already exist in native platforms (iOS/Android), this RFC explores creation of similar plugins in Flutter.
Flutter Plugins/Platform Plugins/Federated Plugins: These are native platform code and modules that is called from flutter apps or libraries over a method channel.

Proposed Solution

High Level Overview

Amplify flutter will be architected as a pluggable interface across all the categories listed in the Goals. The pluggable interface will allow plugging in different cloud providers (e.g. Auth0 or Cognito for Auth category) which can be written either entirely in Dart or using Flutter's Platform Plugins to reuse native (iOS and/or android) modules.

The core of Amplify Flutter will be written in Dart which provides the pluggable interface and out of the box AWS cloud provider plugins will utilize existing Amplify Android and Amplify iOS libraries as Flutter's federated plugins. This means that we will not be implementing a Dart aws-sdk right away as AWS service calls will be made by Amplify Android/iOS libraries.

The Amplify flutter library will be compatible with Amplify CLI to create and provision your cloud providers' resources. Amplify CLI will generate a configuration file to easily configure your Flutter app to use these resources.

Pros

  1. We can reuse most of the existing Amplify native libraries' AWS providers and ship to customers faster.
  2. Some initial bench-marking proves that executing native platform code is generally faster than dart code.
  3. New features introduced in native libraries can be made available in Flutter with very minimal to no change.
  4. Provides flexibility to write providers' (AWS or others) implementation entirely in Dart if needed in the future.

Amplify Flutter(2)

Developer Experience

  • Creating and provisioning resources will remain the same with amplify CLI https://docs.amplify.aws/cli/start/workflows
  • Integrating with Amplify Flutter
    • Flutter Apps will import AmplifyCore and the plugins they want to use in the app.
    • In the app, developers will be required to call Amplify.addPlugin() for each plugin they import e.g. Amplify.addPlugin(CognitoAuthPlugin())
    • Developers will call Amplify.Category.<API> to use installed plugins, e.g. Amplify.Auth.signIn()
  • Developing and debugging Amplify Flutter
    • Refer official flutter guide to learn how to debug provider plugins that are written entirely in Dart and the ones that use platform federated plugins.
  • Using Amplify UI components for Flutter - Coming Soon

FAQs

Q. Which versions of Android and iOS are supported?
Same versions as supported by Amplify Android and Amplify iOS libraries.

Q. How will escape hatches work with Amplify plugins that use native libraries?
Coming Soon.

Q. How will events that are emitted in native libraries reach Flutter apps.
We will use Flutter's event channels to subscribe events on the native platform and transmit them over to Dart end.

Q. Will web and Desktop platform be supported?
Not right away, our goal with this design is to keep the architecture flexible such that more platforms can be supported in the future.

Q. Can I migrate my Amplify CLI generated config from Android, iOS or JS platform to flutter?
Not right now. We will look into the feasibility of supporting this in the future.

Metadata

Assignees

No one assigned

    Labels

    feature-requestA request for a new feature or an enhancement to an existing API or category.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions