flutter_distribute_manager 4.0.1
flutter_distribute_manager: ^4.0.1 copied to clipboard
Ship Flutter builds to QA in one command: build APK, App Bundle or IPA, then upload to Google Drive, Diawi or Firebase App Distribution with install links.
example/flutter_distribute_manager_example.dart
// Demonstrates the reusable building blocks exported by
// flutter_distribute_manager. The CLI (`flutter_distribute_manager`) wires
// these together, but you can embed them in your own release tooling.
//
// Run with: dart run example/flutter_distribute_manager_example.dart
//
// ignore_for_file: avoid_print
import 'dart:io';
import 'package:flutter_distribute_manager/flutter_distribute_manager.dart';
void main() {
// 1. Detect the Flutter project in the current directory (if any).
final project = FlutterProject.detect(Directory.current.path);
print(project == null
? 'No Flutter project in ${Directory.current.path}'
: 'Detected ${project.name} v${project.version}');
// 2. Parse CLI-style values into typed models.
final target = BuildTarget.parse('both');
final env = ReleaseEnvironment.parse('uat');
print('Target: ${target.label}, environment: ${env.tag}');
// 3. Compose a timestamped, environment-tagged artifact name.
final fileName = timestampedFileName(
appName: 'MyApp',
envTag: env.tag,
now: DateTime(2026, 6, 19, 9, 30),
extension: 'apk',
suffix: 'arm64-v8a',
);
print('Artifact name: $fileName');
// 4. Render rclone progress into a branded bar.
final progress = RcloneProgress.tryParse(
'Transferred: \t 42 MiB / 66 MiB, 64%, 4.2 MiB/s, ETA 6s',
);
print(progress?.renderBar());
// 5. Build a structured result and print a notification payload + JSON.
final result = BuildResult(
app: 'MyApp',
version: '1.4.2',
environment: env.tag,
platform: target.id,
artifacts: [
ArtifactResult(
name: fileName,
platform: 'android',
sizeBytes: 24 * 1024 * 1024,
path: 'build/distribute/$fileName',
abi: 'arm64-v8a',
),
],
links: [
DistributionLink(
service: 'Drive',
artifact: fileName,
url: 'https://drive.google.com/file/d/EXAMPLE/view',
),
],
timingsMs: const {'androidBuild': 182000, 'driveUpload': 9400},
);
print(NotificationClient.buildMessage(result));
// 6. Render a summary table.
final table = ConsoleTable(['Artifact', 'Platform', 'Size'])
..addRow([fileName, 'android', humanSize(24 * 1024 * 1024)]);
print(table.render());
// 7. Plan a version bump on pubspec text (only the value changes).
const pubspec = 'name: my_app\nversion: 1.4.2+7 # bumped by CI\n';
final next = PubspecVersion.tryParse('1.4.2+7')!.bump(VersionBumpPart.build);
print(rewritePubspecVersion(pubspec, '$next'));
// 8. Pick what Firebase App Distribution should receive.
final selection = selectFirebaseArtifacts([
BuildArtifact(
file: File('build/distribute/$fileName'),
target: BuildTarget.android,
label: 'arm64-v8a'),
BuildArtifact(
file: File('build/distribute/MyApp_UAT.aab'),
target: BuildTarget.android),
]);
print('Firebase gets: ${selection.android.map((a) => a.name).join(', ')}');
// 9. A SHA256SUMS line and a terminal QR code for an install link.
print(sha256SumsContent({fileName: 'e3b0c442' * 8}));
renderTerminalQr('https://i.diawi.com/AbC123')?.forEach(print);
}