79664785

Date: 2025-06-13 11:46:21
Score: 0.5
Natty:
Report link

If the price is coming as an integer but you wish to make it double why not parse it?

There could several ways but i suggest

{
      'mid': int mid,
      'icode': String icode,
      'name': String name,
      'description': String description,
      'price': num? price, // could be anything (int, double or null)
      'gid': int gid,
      'gname': String gname,
      'pic': String pic,
      'quantity': int quantity,
    } =>
      Product(
        mid: mid,
        icode: icode,
        name: name,
        description: description,
        price: price?.toDouble() ?? 0.0, // if null add default value else make it double
        gid: gid,
        gname: gname,
        pic: pic,
        quantity: quantity,
      ),

This way if price is null you get a default value while if it is int or double either way it will be converted to double.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Muhammad Talha