writeShorebirdYaml static method
Writes a shorebird.yaml configuration file.
This method generates a shorebird.yaml file with the provided configuration settings. The generated file includes the app_id and auto_update settings required by the Shorebird updater.
Parameters:
map: A map containing the Shorebird configuration settings- Must include 'app_id' key
- May include 'auto_update' key (defaults to true)
Example:
final config = {
'app_id': 'your-shorebird-app-id',
'auto_update': true,
};
ShorebirdHelper.writeShorebirdYaml(config);
Throws: ArgumentError if 'app_id' is not provided in the configuration
Implementation
static void writeShorebirdYaml(Map<dynamic, dynamic>? map) {
if (map == null || map.isEmpty) return;
final appId = map['app_id'];
if (appId == null) {
throw ArgumentError('app_id is required in shorebird configuration');
}
final autoUpdate = map['auto_update'] ?? true;
join(current, 'shorebird.yaml').write(
'''# This file is used to configure the Shorebird updater used by your app.
# Learn more at https://docs.shorebird.dev
# This file does not contain any sensitive information and should be checked into version control.
# Your app_id is the unique identifier assigned to your app.
# It is used to identify your app when requesting patches from Shorebird's servers.
# It is not a secret and can be shared publicly.
app_id: $appId
# auto_update controls if Shorebird should automatically update in the background on launch.
# If auto_update: false, you will need to use package:shorebird_code_push to trigger updates.
# https://pub.flutter-io.cn/packages/shorebird_code_push
# Uncomment the following line to disable automatic updates.
auto_update: $autoUpdate
''');
}