os_updater 0.0.2 copy "os_updater: ^0.0.2" to clipboard
os_updater: ^0.0.2 copied to clipboard

OS Updater is in app update for who useing side loading apps for distribute

Flutter In-App Update Package #

The Flutter In-App Update Package 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.

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:
  your_package_name: ^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:your_package_name/your_package_name.dart';

void main() {
  UpdateManager.initialize('YOUR_BACKEND_URL');
  runApp(MyApp());
}

Usage #

  1. Automatic Update Check
    Perform the update check in the initState() method with the following code:

    import 'package:your_package_name/your_package_name.dart';
    import 'package:flutter/scheduler.dart';
    
    @override
    void initState() {
      super.initState();
    
      SchedulerBinding.instance.addPostFrameCallback(
        (timeStamp) async {
          await UpdateManager.instance.checkForUpdate(
            "HidupBanjaran",  // App name
            appVersion,       // Current app version
            context           // Context to display the dialog
          );
        },
      );
    }
    

    Notes:

    • SchedulerBinding ensures 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.
  2. Backend URL Ensure YOUR_BACKEND_URL points 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:your_package_name/your_package_name.dart';
import 'package:flutter/scheduler.dart';

void main() {
  UpdateManager.initialize('https://example.com/backend');
  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(
          "HidupBanjaran",
          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.

0
likes
0
points
47
downloads

Publisher

unverified uploader

Weekly Downloads

OS Updater is in app update for who useing side loading apps for distribute

Homepage

License

unknown (license)

Dependencies

device_info_plus, dio, flutter, open_file, path_provider, permission_handler

More

Packages that depend on os_updater