flutter_siren 0.5.0

Flutter Android iOS

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

🚨 flutter_siren #

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 and Android.

Install #

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

dependencies:
  flutter_siren: <latest-version>

And install the packages from the command line:

$ flutter pub get

Usage #

import 'package:flutter/material.dart';
import 'package:flutter_siren/flutter_siren.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. #

valueDescriptiondefault
titleAlert titleUpdate Available
messageAlert MessageThere is an updated version available on the App Store. Would you like to upgrade?
buttonUpgradeTextUpgrade Button TextUpgrade
buttonCancelTextCancel Button TextCancel
forceUpgradeHide Cancel Buttonfalse
// 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>[],
      );
    }
  }
);

Inspiration #

These awesome packages: Siren and react-native-siren

2
likes
90
pub points
0%
popularity

Publisher

diegocosta.com.br

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, url_launcher

More

Packages that depend on flutter_siren