plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Question]: When I use android_alarm_manager_plus and print something out it works fine but when I try to show notification on completion of alarm it suddenly stops

Open hyderali0889 opened this issue 3 years ago • 0 comments

What is your question?

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

import '../Services/local_notification_services.dart';

class HomeScreen extends StatefulWidget {
  const HomeScreen({super.key});



  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

late final LocalNotificationService service;

 showNot() {
  service.showNotification(id: 0, title: "Hello", body: "Alarm On");
  print("object");

}

class _HomeScreenState extends State<HomeScreen> {
  @override
  void initState() {
    service = LocalNotificationService();
    service.intialize();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Center(
            child: OutlinedButton(
      onPressed: () {
        AndroidAlarmManager.oneShot(Duration(seconds: 2), 0, showNot);
      },
      child: const Text("Press Me"),
    )));
  }
}

This is how I am trying to make it work

hyderali0889 avatar Aug 08 '22 21:08 hyderali0889