flutter_siren_2 1.2.2 copy "flutter_siren_2: ^1.2.2" to clipboard
flutter_siren_2: ^1.2.2 copied to clipboard

One way to notify users when a new version of your app is available and prompt them to upgrade.

flutter_siren_2 #

This fork of flutter_siren fixes a few problems with Android API 33 and has up-to-date dependencies (28 Nov. 2023).

I created the fork mainly because I couldn't compile flutter_siren with a current flutter installation with (Android) because the dependencies were out-of-date and additionally some customization was needed to target API 33 from Android. Unfortunately, the original repo has been archived and is no longer maintained.

Install #

$ flutter pub add flutter_siren_2

New Pub Dev Page

🚨 flutter_siren (Original Readme) #

The Flutter port of the popular Siren, one way to notify users when a new version of your app is available and prompt them to upgrade.

🚀 Supports iOS, Android and MacOS.

Requirements #

Your package must follow the Semantic Versioning

Install #

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_siren_2: <latest-version>

And install the packages from the command line:

$ flutter pub get

Usage #

import 'package:flutter/material.dart';
import 'package:flutter_siren_2/flutter_siren_2.dart';

// Check update on button press with AlertDialog.

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Builder(
          builder: (context) {
            return Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  FlatButton(
                    child: Text('Check Update'),
                    onPressed: () {
                      final siren = Siren();
                      siren.promptUpdate(context);
                    },
                  )
                ],
              ),
            );
          }
        )
      ),
    );
  }
}

Customizing the prompt update. #

value Description default
title Alert title Update Available
message Alert Message There is an updated version available on the App Store. Would you like to upgrade?
buttonUpgradeText Upgrade Button Text Upgrade
buttonCancelText Cancel Button Text Cancel
forceUpgrade Hide Cancel Button false
// Passing custom options.
siren.promptUpdate(context, 
  title: "My alert title", 
  message: "Bro, update my app", 
  buttonUpgradeText: "Download",  
  buttonCancelText: "Nop",
  forceUpgrade: true
);

Building your own prompt update. #

Your can use the updateIsAvailable method to create your own way to alert the user about new updates. This method returns a boolean and you do your magic!

final siren = Siren();

FutureBuilder<bool>(
  future: siren.updateIsAvailable(),
  builder: (context, AsyncSnapshot<bool> snapshot){ 
    if (snapshot.hasData) {
      return AlertDialog(
        title: Text(title),
        content: Text(message),
        actions: <Widget>[],
      );
    }
  }
);

Accessing store and local versions #

Your can use the localVersion or storeVersion getters to access the current version status of your app!

final siren = Siren();

final local = siren.localVersion;
final store = siren.storeVersion;

Inspiration #

These awesome packages: Siren and react-native-siren

1
likes
130
points
44
downloads

Publisher

unverified uploader

Weekly Downloads

One way to notify users when a new version of your app is available and prompt them to upgrade.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http, package_info_plus, url_launcher, version

More

Packages that depend on flutter_siren_2