basic_force_update 1.0.6
basic_force_update: ^1.0.6 copied to clipboard
Basic Force Update
Force Update #
A Flutter package that helps you implement force update functionality in your app. This package provides both dialog and bottom sheet options to prompt users to update your app when a new version is available.
Features #
- ๐ Automatic version checking
- ๐ฑ Support for both iOS and Android platforms
- ๐จ Customizable UI (Dialog and Bottom Sheet options)
- ๐ฅ Firebase Remote Config integration
- ๐งช Dummy provider for testing
- ๐ก๏ธ Type-safe with proper null safety
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
basic_force_update: ^latest_version
Usage #
1. Basic Setup #
Wrap your app's root widget with ForceUpdateWidget:
ForceUpdateWidget(
delegate: ForceUpdateDelegate(
version: '1.0.0', // Your app's current version
type: ForceUpdateType.dialog, // or ForceUpdateType.sheet
title: 'Update Required',
description: 'Please update to the latest version to continue using the app.',
button: 'Update Now',
appStoreId: 'YOUR_APP_STORE_ID', // For iOS
packageName: 'YOUR_PACKAGE_NAME', // For Android
),
provider: const DummyUpdateProvider(
version: '1.0.1',
active: true,
),
child: YourApp(),
);
2. Using Firebase Remote Config #
To use Firebase Remote Config for managing force updates:
ForceUpdateWidget(
delegate: ForceUpdateDelegate(
version: '1.0.0',
type: ForceUpdateType.dialog,
title: 'Update Required',
description: 'Please update to continue.',
button: 'Update Now',
appStoreId: 'YOUR_APP_STORE_ID',
packageName: 'YOUR_PACKAGE_NAME',
),
provider: FirebaseForceUpdateProvider(
key: 'your_remote_config_key', // Optional, defaults to 'update'
),
child: YourApp(),
);
Firebase Remote Config JSON Structure
{
"android": {
"minimum": "1.0.1",
"active": true
},
"ios": {
"minimum": "1.0.1",
"active": true
}
}
3. Custom Update Provider #
You can create your own update provider by implementing the ForceUpdateProvider interface:
class CustomUpdateProvider implements ForceUpdateProvider {
@override
FutureOr<ForceUpdateDetails?> getForceUpdateDetails() {
// Implement your own logic to fetch update details
}
}
ForceUpdateDelegate Properties #
| Property | Type | Description |
|---|---|---|
| version | String | Current app version |
| type | ForceUpdateType | Dialog or Sheet |
| title | String | Update prompt title |
| description | String | Update description |
| button | String | Update button text |
| appStoreId | String? | iOS App Store ID |
| packageName | String? | Android package name |
Providers #
DummyUpdateProvider #
- Useful for testing and development
- Provides static update information
FirebaseForceUpdateProvider #
- Integrates with Firebase Remote Config
- Allows dynamic update management
- Supports different versions for iOS and Android