flutter_siren 1.2.0 copy "flutter_siren: ^1.2.0" to clipboard
flutter_siren: ^1.2.0 copied to clipboard

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

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

class VersionText extends StatelessWidget {
  final Future data;

  const VersionText(this.data, {Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
      builder: (context, snapshot) {
        if (snapshot.hasData) {
          return Text(snapshot.data.toString());
        } else if (snapshot.hasError) {
          return Text(snapshot.error?.toString() ?? "Error");
        } else {
          return const Text('Loading...');
        }
      },
      future: data,
    );
  }
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final siren = Siren();

    return MaterialApp(
      title: 'Flutter Siren Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: Scaffold(
          appBar: AppBar(
            title: const Text('Flutter Siren Demo'),
          ),
          body: Builder(
            builder: (context) => Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  const Text(
                    'Please change the iOS Bundle Identifier or the Android Package namespace for a value of an app published in stores and press the following button to show the update dialog:',
                  ),
                  TextButton(
                    child: const Text('Check Update'),
                    onPressed: () => siren.promptUpdate(context),
                  ),
                  const Text('Local Version:'),
                  VersionText(siren.localVersion),
                  const Text('Store Version:'),
                  VersionText(siren.storeVersion),
                ],
              ),
            ),
          )),
    );
  }
}
17
likes
120
pub points
57%
popularity

Publisher

verified publisherdiegocosta.me

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