- Home
- Dependencies and caching
- Flutter dependencies
Flutter dependencies
Using the official Bitrise Steps, you can easily install and cache Flutter dependencies, including Dart packages and plugin packages.
Flutter supports using shared packages as app dependencies. The packages you can use in your app can be divided into two broad types:
-
Dart packages use only Dart code and can contain dependencies, apps, resources, or tests.
-
Plugins are a special type of package, containing both native Android or iOS code, as well as Dart code. They make platform functionality available to your Flutter apps.
Bitrise Steps can handle both types, and we have efficient caching solutions for all Flutter dependencies.
Installing dependencies for Flutter apps
Our Flutter Build Step can build both the iOS and Android apps of a Flutter project. The Step runs the flutter pub get command to install all dependencies found in your project's pubspec.yaml
file, including
plugin packages. As such, it's really simple to add dependencies to a Flutter app on Bitrise.
Package interdependencies
If your app's dependencies include plugin packages that require access to platform-specific APIs, you need to add the appropriate dependency declarations to the platform-specific build files. For example, you might need to declare a Gradle dependency in the pubspec.yaml
file and in your
project's build.gradle
file as well.
For more information, check out the official Flutter documentation: Handling package interdependencies.
Workflow Editor
bitrise.yml
-
Add dependencies to your Flutter project's
pubspec.yaml
file. -
On Bitrise, add the Flutter Install Step to your Workflow to install the Flutter SDK.
-
Add the Flutter Build Step to your Workflow.
The Step can build both the iOS and Android apps of a Flutter project. If your app's repository contains the necessary build files, it will download and install all required dependencies.
-
Add dependencies to your Flutter project's
pubspec.yaml
file. -
On Bitrise, add the
flutter-install
Step to your Workflow to install the Flutter SDK.your-workflow: steps: - git-clone: {} - flutter-installer: inputs: - is_update: false
-
Add the
flutter-build
Step to your Workflow.your-workflow: steps: - git-clone: {} - flutter-installer: inputs: - is_update: false - flutter-build: {}
The Step can build both the iOS and Android apps of a Flutter project. If your app's repository contains the necessary build files, it will download and install all required dependencies.
Caching dependencies for Flutter apps
There are two ways to cache Flutter dependencies in a build, depending on whether you use key-based caching or branch-based caching.
Key-based caching
Key-based caching is only available for credit-based accounts!
Key-based caching
Branch-based caching
With key-based caching, you only need the Restore Dart cache and the Save Dart cache Steps to cache your Dart dependencies. These Steps require no configuration as they automatically set up the cache keys needed for your dependencies.
Setting specific cache paths
You don't have to use the default cache paths that the dedicated key-based caching Steps use. If you need to set a specific cache path, you can do so by configuring the Save cache and the Restore cache Steps: Using key-based caching in your builds.
-
Add the Restore Dart cache Step before the Flutter Build Step.
We also recommend placing it after the Flutter Install Step.
-
Add the Save Dart cache Step to the end of your Workflow.
Branch-based caching relies on the built-in feature of the Flutter Build Step to cache Dart packages, Gradle dependencies, Carthage and CocoaPods dependencies.
Setting specific cache paths
You don't have to use the default cache paths that the built-in caching options use. If you need to set a specific cache path, you can do so in the Bitrise.io Cache:Pull and the Bitrise.io Cache:Push Steps: Including files and folders in the build cache.
-
Add the Bitrise.io Cache:Pull Step to your Workflow.
It should come before any Step that builds your app.
-
Set the Build cache of input of the Flutter Build Step to all.
The Step will cache all dependencies.
-
Add the Bitrise.io Cache:Push Step to the end of your Workflow.
The Step requires no extra configuration if you use the Flutter Build Step.
A Step is a block of script execution that encapsulates a build task on Bitrise: the code to perform that task, the inputs and parameters you can define for the task, and the outputs the task generates.
A Workflow is a collection of Steps, Environment Variables, and other configurations. When Bitrise starts a build, it runs one or more Workflows according to the configuration defined in the bitrise.yml
file.