Search packages, repositories and app categories

Package detailsv1.0.2

flutter_alarm_background_trigger

A flutter plugin for Android to launch app from background at specific time just like stock alarm app in Android.

Android
30-day downloads
41
Likes
44
Pub points
140

Install package

flutter pub add flutter_alarm_background_trigger

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter plugin for Android that enables launching an app from the background at a specified time, mimicking the behavior of the native Android alarm app. It allows developers to schedule app wake-ups even when the app is closed or the device is in deep sleep, making it ideal for alarm, reminder, and timed notification applications. The plugin leverages Android's JobScheduler and AlarmManager APIs to ensure reliable execution. It does not support iOS. The package is lightweight and integrates seamlessly with existing Flutter projects.

Use cases

  • Scheduling alarms
  • Implementing reminder apps
  • Triggering background tasks at specific times
  • Creating time-based notifications
  • Enabling app launch from sleep mode

Key features

  • Background app launch
  • Android-only support
  • Uses JobScheduler and AlarmManager
  • Simple integration with Flutter
  • Reliable timing for scheduled events

Suitable for

  • Alarm application developers
  • Reminder system builders
  • Time-triggered background processing
  • Android-focused Flutter apps
  • Apps requiring precise wake-up scheduling

Considerations

  • Only works on Android
  • Requires proper Android manifest configuration
  • May be affected by battery optimization settings
  • Limited to Android platform
  • Needs user permission for background execution

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Flutter background alarm trigger

A flutter plugin for Android to launch app from background at specific time just like stock alarm app in Android

Installation
flutter_alarm_background_trigger: ^1.0.0
# or
flutter pub add flutter_alarm_background_trigger
Initialization
void main() {
  // Very important to call before initialize since it 
  // ensures the binding is available and ready before 
  // any native call
  WidgetsFlutterBinding.ensureInitialized();

  // initialize Required for alarm events to bind with flutter method channel
  FlutterAlarmBackgroundTrigger.initialize();

  runApp(const MyApp());
}

Create instance
var alarmPlugin = FlutterAlarmBackgroundTrigger();
Set Alarm
alarmPlugin.addAlarm(
      // Required
      DateTime.now().add(Duration(seconds: 10)),

      //Optional
      uid: "YOUR_APP_ID_TO_IDENTIFY",
      payload: {"YOUR_EXTRA_DATA":"FOR_ALARM"},

      // screenWakeDuration: For how much time you want 
      // to make screen awake when alarm triggered
      screenWakeDuration: Duration(minutes: 1)
  )
Receive event when alarm trigger
alarmPlugin.requestPermission().then((isGranted){
  if(isGranted){
    alarmPlugin.onForegroundAlarmEventHandler((alarm){
      // Perform your action here such as navigation
      // This event will be triggered on both cases, 
      // when app is in foreground or background!
      print(alarm.id)
    })
  }
})

Additional methods

Request permission to draw over other apps
Future<bool> requestPermission()
Add
Future<AlarmItem> addAlarm(
  DateTime time, 
  {
    String? uid, 
    Map<String, dynamic>? payload, 
    Duration screenWakeDuration
  }
)
Get alarm by uid
Future<List<AlarmItem>> getAlarmByUid(String uid)
Get all scheduled alarms
Future<List<AlarmItem>> getAllAlarms()
Get single alarm
Future<AlarmItem> getAlarm(int id)
Get alarm by payload
Future<List<AlarmItem>> getAlarmByPayload(Map<String, dynamic> payload)
Get alarm by time
Future<List<AlarmItem>> getAlarmByTime(DateTime time)
Alarm trigger event
void onForegroundAlarmEventHandler(OnForegroundAlarmEvent alarmEvent)
Delete single alarm
Future<void> deleteAlarm(int id)
Delete by payload
Future<void> deleteAlarmsByPayload(Map<String, dynamic> payload)
Delete by time
Future<void> deleteAlarmsByTime(DateTime dateTime)
Delete by uid
Future<void> deleteAlarmsByUid(String uid)
Delete all scheduled alarms
Future<void> deleteAllAlarms()

Categories

Dependencies

Dependency list 1 items

  • plugin_platform_interface^2.0.2

Source repository

Projects using this package

No data available yet.