gdelataillade / alarm

A Flutter plugin to easily manage alarms on iOS and Android
https://pub.dev/packages/alarm
MIT License
132 stars 86 forks source link

Accept id param as 64-bit integer #31

Closed sandamil closed 1 year ago

sandamil commented 1 year ago

I/flutter (18061): [Alarm] Schedule notification with id 1681220774151384 error: Invalid argument (id): must fit within the size of a 32-bit integer i.e. in the range [-2^31, 2^31 - 1]: 1681220774151384

if is posible, when generate a uuid is not posible to use a >32bit int, Can Refactor?

gdelataillade commented 1 year ago

Hi @sandamil

Thank you for your interest in the package !

Unfortunately, the types long or int64_t are not supported in Dart. For large storage integers, there's the BigInt type. This variable causes performance and memory issues due to its arbitrary precision though. In addition, I'm working with APIs that only allow an int as id (android_alarm_manager_plus). Then, it is definitely not possible for this plugin to use >32bit integers.

You should try to divide or use a bitwise AND operator to mask the higher bits to reduce the size of your number so it can be stored in a int.

Let me know if you have any other questions.

sandamil commented 1 year ago

Yes, I have changed it and generated a shorter id, I wanted to use a library that generated uuid, for this but it gave me an error, I understand that it cannot be used and I think that it will not be a problem for me, thanks for the answer and your time!