Giter VIP home page Giter VIP logo

flutter_siren's Introduction

๐Ÿšจ 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, Android and MacOS.

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.

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.