braze-inc / braze-flutter-sdk

Public repo for the Braze Flutter SDK
Other
15 stars 29 forks source link

[Bug]: Content card image aspect ratio decode bug #52

Closed gbassipxl closed 10 months ago

gbassipxl commented 1 year ago

Hey there, just mentioning that there is a bug in the deserialisation logic for the BrazeContentCard.imageAspectRatio property: https://github.com/braze-inc/braze-flutter-sdk/blob/master/lib/braze_plugin.dart#L680

When ratio is an integer, it doesn't meet that condition logic and keeps its default value of 1. Pretty easy to confirm with the following test:

// bug not parsing aspect ratio if it is an int
final card = BrazeContentCard('{"ar":2}');
expect(card.imageAspectRatio, isNot(2));

// but it parses if it's a double
final card2 = BrazeContentCard('{"ar":2.0}');
expect(card2.imageAspectRatio, 2);

Quick and simple fix would be to replace that condition logic by: imageAspectRatioJson is num Implicit cast will take care of integers upon assignment.

I can work around it no problem, but I'd love not having to :)

Thanks!

hokstuff commented 1 year ago

Hi @gbassipxl,

Thanks for raising this issue - we have filed a ticket internally to make the change, and we will respond on this thread once it is released.

hokstuff commented 10 months ago

Hi @gbassipxl,

We have released Flutter version 6.0.0 which fixes this issue. Thanks for bringing it to our attention!