This guide will walk you through how to set up an app in which there are 2
deployment flavors: internal and stable. It will cover how to validate a
patch on the internal flavor and then promote the patch to the stable flavor on
Android.
This guide assumes the Shorebird command-line is installed on your machine and
that you are logged into an account. Refer to the
getting started instructions for
more information.
Next, re-initialize Shorebird in the current project via
shorebird init --force to update the YAML file.
shorebird init --force
The generated shorebird.yaml should look something like:
# This file is used to configure the Shorebird updater used by your application.# Learn more at https://shorebird.dev# This file should be checked into version control.# This is the unique identifier assigned to your app.# It is used by your app to request the correct patches from Shorebird servers.app_id: ee322dc4-3dc2-4324-90a9-04c40a62ae76flavors: internal: ee322dc4-3dc2-4324-90a9-04c40a62ae76 stable: 904bd3d5-3526-4c1c-a832-7ac23c95302d
Because the project contains flavors, shorebird init now generates an app per
flavor, and you can validate the release flavor by visiting the
Shorebird console.
Now that the apps have been created on Shorebird, releases need to be created
(one for each flavor), using the shorebird release android command.
# Create a release for the internal flavorshorebird release android --flavor internal# Create a release for the stable flavorshorebird release android --flavor stable
Verify the releases were created successfully by visiting the
Shorebird console.
To preview the app release locally on a device or emulator, use
shorebird preview.
# Preview the release for the internal flavor.shorebird preview --app-id ee322dc4-3dc2-4324-90a9-04c40a62ae76 --release-version 1.0.0+1# Preview the release for the stable flavor.shorebird preview --app-id 904bd3d5-3526-4c1c-a832-7ac23c95302d --release-version 1.0.0+1
This will download the releases and run them on your device.
In addition to previewing the releases locally, you should also
submit the generated app bundles to the Play Store.
In this case, both apps can be part of the internal test flavor and only the
stable variant should be promoted to production.
Now that the internal and stable releases are on the Play Store, a patch can be
created using shorebird patch android. For the sake of this example, adjust
the app theme to use deepOrange as the seed color in lib/main.dart:
class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( // This is the theme of your application. // // TRY THIS: Try running your application with "flutter run". You'll see // the application has a blue toolbar. Then, without quitting the app, // try changing the seedColor in the colorScheme below to Colors.green // and then invoke "hot reload" (save your changes or press the "hot // reload" button in a Flutter-supported IDE, or press "r" if you used // the command line to start the app). // // Notice that the counter didn't reset back to zero; the application // state is not lost during the reload. To reset the state, use hot // restart instead. // // This works for code too, not just values: Most code changes can be // tested with just a hot reload.- colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),+ colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange), useMaterial3: true, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); }}
Now that the changes have been applied, patch the internal variant:
shorebird patch android --flavor internal
Validate the patch by visiting the
Shorebird console, then selecting the internal
release, or by relaunching the internal release.
The first time the app is re-launched, the purple theme should still be visible,
and Shorebird will detect and install the patch in the background. Kill and
re-launch the app a second time to see the applied patch.
If all went well, you should see the patch was applied after re-launching the
app a second time. All devices that have the internal variant of the app
installed should also receive the patch 🎉