os_updater 0.0.5
os_updater: ^0.0.5 copied to clipboard
OS Updater is in app update for who useing side loading apps for distribute
OS Updater #
The OS Updater is a solution for managing in-app updates in your Flutter application, particularly for apps distributed through sideloading. This package allows you to easily detect and manage application updates without complex integration.
You need dashboard integration for managing updates #
Take a look at my github repository Backend Project Frontend Project
Features #
- Automatic Update Detection: Checks if the latest version of the app is available.
- Interactive Interface: Displays a dialog for users to decide whether to download the update.
- Sideloading Support: Ideal for apps not distributed via the Google Play Store.
- Permission Management: Automatically handles all necessary permissions.
Installation #
1. Add to pubspec.yaml #
Add the package dependency to your pubspec.yaml file:
dependencies:
os_updater: ^1.0.0
2. Android Configuration #
In your Android app, add the following permissions to the AndroidManifest.xml file:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
3. Initialize in Flutter Code #
Add the following initialization in main() to set up your backend URL:
import 'package:os_updater/os_updater.dart';
void main() {
UpdateManager.initialize('YOUR_BACKEND_URL', splittedAPK: true, appsKey: "YORU_APP_KEY");
runApp(MyApp());
}
set splittedAPK to true if you build your flutter apk with --split-per-abi
set appsKey same as .env on your backend server
Usage #
-
Automatic Update Check
Perform the update check in theinitState()method with the following code:import 'package:os_updater/os_updater.dart'; import 'package:flutter/scheduler.dart'; @override void initState() { super.initState(); SchedulerBinding.instance.addPostFrameCallback( (timeStamp) async { await UpdateManager.instance.checkForUpdate( "YourAppName", // App name appVersion, // Current app version context // Context to display the dialog ); }, ); }Notes:
SchedulerBindingensures that the widget's state has fully loaded before performing the update check.- An interactive dialog will be displayed for users to decide whether to download the update.
-
Backend URL Ensure
YOUR_BACKEND_URLpoints to the server that provides metadata for the latest app version.
Permissions #
This package automatically requests the following permissions from the user:
- WRITE_EXTERNAL_STORAGE: Saves the update file.
- READ_EXTERNAL_STORAGE: Reads the update file.
- REQUEST_INSTALL_PACKAGES: Allows installing the APK package.
Full Example #
Here is a complete implementation example:
import 'package:flutter/material.dart';
import 'package:os_updater/os_updater.dart';
import 'package:flutter/scheduler.dart';
void main() {
UpdateManager.initialize('https://example.com/backend',splittedAPK: true, appsKey: "YORU_APP_KEY");
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomeScreen(),
);
}
}
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
final String appVersion = "1.0.0";
@override
void initState() {
super.initState();
SchedulerBinding.instance.addPostFrameCallback(
(timeStamp) async {
await UpdateManager.instance.checkForUpdate(
"YourAppName",
appVersion,
context,
);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('In-App Update Example'),
),
body: Center(
child: Text('Welcome to the app!'),
),
);
}
}
License #
This package is licensed under the MIT License.