Page updated Mar 6, 2024

Set up fullstack project

Set up your application

Create a new Flutter application

Create a new project using Flutter CLI:

1flutter create budget_tracker

Add Amplify to your application

Amplify Flutter is distributed via pub.dev.

  1. From your project root directory, find and modify your pubspec.yaml and add the Amplify plugins to the project dependencies.

    1environment:
    2 sdk: ">=2.18.0 <3.0.0"
    3
    4dependencies:
    5 amplify_api: ^1.0.0
    6 amplify_auth_cognito: ^1.0.0
    7 amplify_authenticator: ^1.0.0
    8 amplify_flutter: ^1.0.0
    9 flutter:
    10 sdk: flutter
    11 go_router: ^6.5.5
  2. Install the dependencies by running the following command. Depending on your development environment, you may perform this step via your IDE (or it may even be performed for you automatically).

    1flutter pub get

Platform Setup

Depending on the platform you're building for, some extra set up may be required.

Amplify requires a minimum deployment target of 13.0 and Xcode 13.2 or higher when targeting iOS.

From your project root, navigate to the ios/ directory and open the Podfile in a text editor of your choice. At the top of the file, update the target iOS platform to 13.0 or higher.

1platform :ios, '13.0'

Open your project in Xcode and select Runner, Targets -> Runner and then the "General" tab. Under the "Minimum Deployments" section, update the iOS version to 13.0 or higher.

Setting the iOS version to 13.0 or higher in the minimum deployments section of the Runner general window.

Select Runner, Project -> Runner and then the "Info" tab. Update "iOS Deployment Target" to 13.0 or higher.

Setting the iOS version to 13.0 or higher in the deployment targets section of the Runner info window.

Amplify requires a minimum of API level 24 (Android 7.0), Gradle 7 and Kotlin > 1.7 when targeting Android.

From your project root, navigate to the android/ directory and open build.gradle in the text editor of your choice. Update the Gradle plugin version to 7.4.2 or higher:

1dependencies {
2- classpath 'com.android.tools.build:gradle:7.2.0'
3+ classpath 'com.android.tools.build:gradle:7.4.2'
4 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
5 }

If your Kotlin Gradle plugin version is below 1.7, update android/build.gradle:

1ext.kotlin_version = '1.7.10'

Then, open android/gradle/wrapper/gradle-wrapper.properties. Update the Gradle distributionUrl to a version between 7.3 and 7.6.1 (see the Flutter docs for more info).

1-distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip
2+distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip

Then, open android/app/build.gradle. Update the minimum Android SDK version to 24 or higher:

1defaultConfig {
2 // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
3 applicationId "com.example.myapp"
4 // You can update the following values to match your application needs.
5 // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
6- minSdkVersion flutter.minSdkVersion
7+ minSdkVersion 24
8 targetSdkVersion flutter.targetSdkVersion
9 versionCode flutterVersionCode.toInteger()
10 versionName flutterVersionName
11 }

There are no Amplify specific requirements or setup instructions when targeting web. You will need to use a browser supported by Flutter. See the following Flutter docs for more info:

Amplify requires a minimum deployment target of 10.15 and Xcode 13.2 or higher when targeting macOS. Additionally, you will need to enable networking, keychain entitlements, and code signing.

Update Minimum Version

From your project root, navigate to the macos/ directory and open the Podfile in a text editor of your choice. Update the target macOS platform to 10.15 or higher.

1platform :osx, '10.15'

Open your project in Xcode and select Runner, Targets -> Runner and then the "General" tab. Under the "Minimum Deployments" section, update the macOS version to 10.15 or higher.

Setting the macOS version to 10.15 or higher in the Minimum Deployments tab of the Runner general section.

Select Runner, Project -> Runner and then the "Info" tab. Update "macOS Deployment Target" to 10.15 or higher.

Setting the macOS version to 10.15 or higher in the MacOS Deployment Target tab of the Runner info section.

Enable Network Calls

Open your project in Xcode and select Runner, Targets -> Runner and then the "Signing and Capabilities" tab. Under "App Sandbox" select "Outgoing Connections (Client)".

Selecting outgoing connections in the app sandbox section of the runner signing and capabilities tab.

For more info on the Networking entitlement, see Apple's documentation on com.apple.security.network.client.

Enable Keychain Sharing

This capability is required because Amplify uses the Data Protection Keychain on macOS as a platform best practice. See TN3137: macOS keychain APIs and implementations for more information on how Keychain works on macOS and the Keychain Sharing entitlement.

Open your project in Xcode and select Runner, Targets -> Runner and then the "Signing and Capabilities" tab.

  1. Click the "+ icon".

Plus icon circled in the signing and capabilities section of the runner tab.

  1. Search for "Keychain Sharing" in the subsequent modal, and add it.

Keychain Sharing search result after searching keychain.

  1. Scroll down to "Keychain Sharing" in the "Signing and Capabilities" and click the "+" icon. By default, your bundle ID will be used.

Plus icon highlighted in the keychain sharing section of the signing and capabilities section of runner.

  1. Finally, add a development team and enable signing.

Team selector and Enable Development Signing button highlighted in the signing and capabilities section of the runner tab.

There are no Amplify specific requirements or setup instructions when targeting Windows. You will need to use a Windows version supported by Flutter. See the following Flutter docs for more info:

Depending on how your Windows configuration and the method you use to run your Flutter app, you may need to change the file path length limitation.

Amplify Flutter depends on the libsecret library when targeting Linux.

Local Development

To run and debug an app that depends on Amplify Flutter, you must install libsecret-1-dev.

To install on Ubuntu, run:

1sudo apt-get update
2sudo apt-get install -y libsecret-1-dev

This will install libsecret-1-dev and any dependencies of libsecret-1-dev, such as libglib2.0-dev, which are also required to run and debug apps that depend on Amplify Flutter.

The command to install might vary on other Linux distributions.

Packaging Your App

To include the required dependencies when packaging your app with Snapcraft, include them in your snapcraft.yaml file. For more info, see Flutter's documentation on releasing to the Snap Store.

1parts:
2 my-app:
3 plugin: flutter
4 source: .
5 flutter-target: lib/main.dart
6 build-packages:
7 - libsecret-1-dev
8 stage-packages:
9 - libsecret-1-0