mmvergara / supadart

Typesafe queries in Supabase Flutter! Generate Flutter / Dart 🎯 classes from your Supabase schema.
https://supadart.vercel.app
MIT License
43 stars 5 forks source link

Incorrect num parsing #67

Closed damywise closed 2 months ago

damywise commented 2 months ago

Hi, thanks for this great package. It's been very helpful for my project.

I encountered an issue with parsing num on version 1.5.6

It generates

sellingPrice: json['selling_price'] != null ? num.parse(json['selling_price']) : 0,

Which results in errors like Unhandled Exception: type 'double' is not a subtype of type 'String' Unhandled Exception: type 'int' is not a subtype of type 'String'

So to fix it I added toString() after the json[key]:

sellingPrice: json['selling_price'] != null ? num.parse(json['selling_price'].toString()) : 0,

I'm guessing the problem is somewhere in this line https://github.com/mmvergara/supadart/blob/f2d03975d325c5a833f5b33e20ab2352ddf4f6e1/cli/lib/generators/class/from_json.dart#L59

mmvergara commented 2 months ago

Thanks for opening up an issue. will fix this shortly.

mmvergara commented 2 months ago

@damywise should be fix. please update your cli to 1.5.7 https://github.com/mmvergara/supadart/pull/68 please let me know if you're still having problems, thanks again

damywise commented 2 months ago

Can confirm it's fixed thanks