flutter_distribute_manager 1.0.0
flutter_distribute_manager: ^1.0.0 copied to clipboard
A professional CLI that builds, packages and ships Flutter apps to QA — Android APK and iOS IPA — with Google Drive uploads via rclone and Diawi 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());
}