growthbook / growthbook-flutter

GrowthBook Flutter SDK
MIT License
6 stars 0 forks source link

Hashing doesn't work on Flutter Web #23

Closed kobreu closed 1 month ago

kobreu commented 2 months ago

Hi,

I noticed that the FNV Hashing doesn't work on Flutter web. The problem is in this line of gb_utils.dart:

final int mod32 = 1 << 32; // Equivalent to 2^32

on web this evaluates to 0 as on web shift operators operate on 32-bit integers (see here: https://stackoverflow.com/questions/307179/what-is-javascripts-highest-integer-value-that-a-number-can-go-to-without-losin)

The fix would be to change the line to

final int mod32 = 0x100000000; // Equivalent to 2^32

Best regards,

Korbinian

vazarkevych commented 2 months ago

Hi, @kobreu. Thank you for mentioning that. You're right, we will add this change to our next release.

vazarkevych commented 1 month ago

Hi, @kobreu. Here is al link to pull request with fix.

kobreu commented 1 month ago

Great, thanks!