# Flutter

Source: https://help.testapp.io/flutter/

Build your Flutter app and send it to your testers with one extra command. This works on your own machine and in any CI. You can upload with **ta-cli** (the quickest way) or with the **fastlane plugin** if you already use fastlane.

## Before you start

- An **API token**: create one at [https://portal.testapp.io/profile/tokens](https://portal.testapp.io/profile/tokens)
- Your **App ID**: open your app in the portal ([https://portal.testapp.io/apps](https://portal.testapp.io/apps)), go to Integrations → Releases, pick any tool, and copy the App ID from the setup panel.

## Option 1: Upload with ta-cli (easiest)

Install ta-cli once:

```bash
curl -Ls https://github.com/testappio/cli/releases/latest/download/install | bash
```

### Android

```bash
flutter build apk --release
ta-cli publish --api_token=$TESTAPPIO_API_TOKEN --app_id=$TESTAPPIO_APP_ID --release=android --apk=build/app/outputs/flutter-apk/app-release.apk --git_release_notes=true --notify=true --source="Flutter"
```

TestApp.io installs APK files. An App Bundle (`.aab`) is for the Play Store and cannot be installed directly on a device, so build an APK for testing.

### iOS

Testers can only install an IPA signed with an **Ad Hoc** or **Development** profile that includes their devices. Signing setup is covered in the Flutter docs: [https://docs.flutter.dev/deployment/ios](https://docs.flutter.dev/deployment/ios)

```bash
flutter build ipa --release --export-method ad-hoc
ta-cli publish --api_token=$TESTAPPIO_API_TOKEN --app_id=$TESTAPPIO_APP_ID --release=ios --ipa=build/ios/ipa/YourApp.ipa --git_release_notes=true --notify=true --source="Flutter"
```

Replace `YourApp.ipa` with the file name Flutter prints at the end of the build.

### Both platforms in one upload

```bash
ta-cli publish --api_token=$TESTAPPIO_API_TOKEN --app_id=$TESTAPPIO_APP_ID --release=both --apk=build/app/outputs/flutter-apk/app-release.apk --ipa=build/ios/ipa/YourApp.ipa --notify=true --source="Flutter"
```

## Option 2: Upload with the fastlane plugin

Already using fastlane? The TestApp.io plugin builds on the same ta-cli upload and fits into your existing lanes. It needs Ruby 3.0 or newer. See the [fastlane plugin guide](https://help.testapp.io/fastlane-plugin/) for every option.

Install the plugin from your Flutter project root (create the `fastlane` folder first with `fastlane init` if you don't have one):

```bash
fastlane add_plugin testappio
```

Add two lanes to `fastlane/Fastfile`. Lanes run inside the `fastlane` folder, so file paths start with `../`:

```ruby
lane :beta_android do
  sh("cd .. && flutter build apk --release")

  upload_to_testappio(
    api_token:         ENV["TESTAPPIO_API_TOKEN"],
    app_id:            ENV["TESTAPPIO_APP_ID"],
    release:           "android",
    apk_file:          "../build/app/outputs/flutter-apk/app-release.apk",
    git_release_notes: true,
    notify:            true
  )
end

lane :beta_ios do
  sh("cd .. && flutter build ipa --release --export-method ad-hoc")

  upload_to_testappio(
    api_token:         ENV["TESTAPPIO_API_TOKEN"],
    app_id:            ENV["TESTAPPIO_APP_ID"],
    release:           "ios",
    ipa_file:          "../build/ios/ipa/YourApp.ipa",
    git_release_notes: true,
    notify:            true
  )
end
```

Run a lane with `fastlane beta_android` or `fastlane beta_ios`. To upload both files at once, use `release: "both"` and pass `apk_file` and `ipa_file`. The plugin marks the upload as coming from fastlane for you, so there is no `source` option to set. Signing for iOS is covered in [Setup iOS Project for Fastlane](https://help.testapp.io/setup-ios-project-for-fastlane/).

## In CI

Run the same commands as the last step of your pipeline and store the token and App ID as secret variables. We have guides for GitHub Actions, GitLab CI/CD, Bitbucket Pipelines, Codemagic, Bitrise, CircleCI, Jenkins, Azure Pipelines and Xcode Cloud.

> **Tip:** Once your pipeline uploads a build, team members using the [TestApp.io mobile app](https://help.testapp.io/mobile-app-getting-started/) receive a push notification and can install the build with a single tap. You can also create [share links](https://help.testapp.io/how-to-share/) to distribute builds to external testers and clients.

---

Need help? [Contact us](https://testapp.io/contact-us/). we're happy to assist!
