init static method
Initialize the auto-updater with ReleaseHub backend.
Call this once at app startup, typically in your main() function.
baseUrl - The ReleaseHub server URL (e.g., 'https://app.v2.sk')
projectSlug - Your project's slug/identifier
channel - Release channel (default: 'stable')
checkOnStartup - Whether to check for updates on init (default: true)
startupDelay - Delay before startup check (default: 3 seconds)
primaryColor - Color for UI elements (default: teal)
strings - Custom strings for localization
Example:
await AutoUpdater.init(
baseUrl: 'https://app.v2.sk',
projectSlug: 'my-app',
channel: 'stable',
);
With localization:
await AutoUpdater.init(
baseUrl: 'https://app.v2.sk',
projectSlug: 'my-app',
strings: AutoUpdaterStrings(
updateAvailable: 'Aktualizácia dostupná',
download: 'Stiahnuť',
later: 'Neskôr',
),
);
Implementation
static Future<void> init({
required String baseUrl,
required String projectSlug,
String channel = 'stable',
bool checkOnStartup = true,
Duration startupDelay = const Duration(seconds: 3),
Color primaryColor = const Color(0xFF0D9488), // Teal
AutoUpdaterStrings strings = const AutoUpdaterStrings(),
}) async {
if (_instance != null) {
debugPrint('[AutoUpdater] Already initialized');
return;
}
final config = AutoUpdaterConfig.releaseHub(
baseUrl: baseUrl,
projectSlug: projectSlug,
channel: channel,
checkOnStartup: checkOnStartup,
startupDelay: startupDelay,
);
_instance = AutoUpdaterStandalone(
config: config,
ui: AutoUpdaterDefaultUI.create(
primaryColor: primaryColor,
strings: strings,
navigatorKey: _navigatorKey,
scaffoldMessengerKey: _scaffoldKey,
),
);
await _instance!.initialize();
debugPrint('[AutoUpdater] Initialized for $projectSlug on $baseUrl');
}