We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm used to work with immutable object to avoid side effect problems. Would be nice if the generator can adapt if the class is immutable :)
Example let's consider this class:
@immutable class CartItem { final int id; final double amount; final String product; final int quantity; const CartItem({this.amount, this.product, this.quantity, this.id}); String get amountLabel => kNumberFormat.format(amount); @override String toString() => 'amount=$amount, quantity=$quantity, product=$product'; CartItem copy({int id, int quantity, String product, double amount}) { return CartItem( amount ?? this.amount, product ?? this.product, quantity ?? this.quantity, id: id ?? this.id, ); } @override bool operator ==(Object other) => identical(this, other) || other is CartItem && runtimeType == other.runtimeType && amount == other.amount && product == other.product && quantity == other.quantity; @override int get hashCode => amount.hashCode ^ product.hashCode ^ quantity.hashCode; }
Then the generated fromMap look like:
fromMap
CartItemDb fromMap(Map map) { CartItemDb model = new CartItemDb(); model.id = adapter.parseValue(map['id']); model.amount = adapter.parseValue(map['amount']); model.product = adapter.parseValue(map['product']); model.quantity = adapter.parseValue(map['quantity']); model.cartId = adapter.parseValue(map['cart_id']); return model; }
Where the correct way would be:
CartItemDb fromMap(Map map) { CartItemDb model = new CartItemDb( id: adapter.parseValue(map['id']), amount: adapter.parseValue(map['amount']), product: adapter.parseValue(map['product']), quantity: adapter.parseValue(map['quantity']), cartId: adapter.parseValue(map['cart_id']), ); return model; }
Might have some changes to do around association too as it directly change the object:
void associateCartDb(CartItemDb child, CartDb parent) { child.cartId = parent.id; }
When I understand better how this generation works I might take a look at this :)
The text was updated successfully, but these errors were encountered:
Very important. Low prio. Will implement this in a week's time.
Sorry, something went wrong.
Hey @tejainece what about this ? :) would be nice to have it like it is in jaguar_serializer ^^
Will work on this next week.
This si fixed.
No branches or pull requests
I'm used to work with immutable object to avoid side effect problems. Would be nice if the generator can adapt if the class is immutable :)
Example let's consider this class:
Then the generated
fromMap
look like:Where the correct way would be:
Might have some changes to do around association too as it directly change the object:
When I understand better how this generation works I might take a look at this :)
The text was updated successfully, but these errors were encountered: