shorebird_updater 1.1.5
shorebird_updater: ^1.1.5 copied to clipboard
Flutter package to integrate Shorebird Code Push updates with customizable UI.
import 'package:flutter/material.dart';
import 'package:shorebird_updater/shorebird_updater.dart';
/// Global navigator key so the updater can show dialogs from anywhere.
final navigatorKey = GlobalKey<NavigatorState>();
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await ShorebirdUpdater.initialize(
navigatorKey: navigatorKey,
// All fields are optional. The app name and logo are detected
// automatically — only override what you need.
config: UpdaterConfig(
logo: const FlutterLogo(),
updateMessage: 'A new version is available. Update now?',
),
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Shorebird Updater Example',
navigatorKey: navigatorKey,
theme: ThemeData(colorSchemeSeed: Colors.blue, useMaterial3: true),
// Wrapping with ShorebirdUpdaterWidget triggers the automatic
// check-for-updates flow when the app launches.
home: const ShorebirdUpdaterWidget(child: HomePage()),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Shorebird Updater')),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text('The app checks for updates automatically on launch.'),
const SizedBox(height: 24),
FilledButton.icon(
onPressed: ShorebirdUpdater.checkForUpdates,
icon: const Icon(Icons.refresh),
label: const Text('Check for updates manually'),
),
],
),
),
);
}
}