timmaffett / custom_mouse_cursor

Custom mouse cursors for Flutter (windows, linux, macos, web) Device Pixel Ratio Aware
Apache License 2.0
6 stars 1 forks source link

Cursor key duplication #3

Closed jinjee89 closed 5 months ago

jinjee89 commented 5 months ago

math.Random random = math.Random(DateTime.now().millisecond);

When generating a random key, millisecond is used as the seed of the random function as shown above, which causes duplicate keys to be generated. When quickly creating multiple cursors using a for statement, there is a problem that the same random seed is used and they end up having the same keys.

timmaffett commented 5 months ago

@jinjee89 Thanks for filing this issue! I have released a new version (1.1.1) which uses DateTime.now().microsecond for the seed and then keeps the Random() generator around so future seeds are never required anyway. This way 16 .nextInt() would have to repeat the previous 16 to get an identical key, which should probably never occur with a good random generator.