android_alarm_manager 0.4.5+2 copy "android_alarm_manager: ^0.4.5+2" to clipboard
android_alarm_manager: ^0.4.5+2 copied to clipboard

discontinued
outdated

Flutter plugin for accessing the Android AlarmManager service, and running Dart code in the background when alarms fire.

example/lib/main.dart

// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// ignore_for_file: public_member_api_docs

import 'dart:async';

import 'package:android_alarm_manager/android_alarm_manager.dart';
import 'package:flutter/widgets.dart';

void printMessage(String msg) => print('[${DateTime.now()}] $msg');

void printPeriodic() => printMessage("Periodic!");
void printOneShot() => printMessage("One shot!");

Future<void> main() async {
  final int periodicID = 0;
  final int oneShotID = 1;

  WidgetsFlutterBinding.ensureInitialized();

  // Start the AlarmManager service.
  await AndroidAlarmManager.initialize();

  printMessage("main run");
  runApp(const Center(
      child:
          Text('See device log for output', textDirection: TextDirection.ltr)));
  await AndroidAlarmManager.periodic(
      const Duration(seconds: 5), periodicID, printPeriodic,
      wakeup: true, exact: true);
  await AndroidAlarmManager.oneShot(
      const Duration(seconds: 5), oneShotID, printOneShot);
}
362
likes
0
pub points
83%
popularity

Publisher

verified publisherflutter.dev

Flutter plugin for accessing the Android AlarmManager service, and running Dart code in the background when alarms fire.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on android_alarm_manager