Ad

How To Generate A Unique Id, Flutter

I am making a todo app with notifications and am using flutter local notifications plugin, How do I generate a unique integer as id for a specific todo so that I can also cancel notification of that specific todo using that unique integer.

Ad

Answer

You can use UniqueKey().hashCode() to get a unique int.
For example:

final notificationId = UniqueKey().hashCode()
// or you can use DateTime.now().millisecondsSinceEpoch
...
Ad
source: stackoverflow.com
Ad