LukeMoody01 / mason_bricks

A collection of bricks that enable developers to be more productive when writing code.
MIT License
109 stars 43 forks source link

feat: Added toString() override #28

Closed ashishbeck closed 1 year ago

ashishbeck commented 1 year ago

Brick

Status

READY

Breaking Changes

NO

Description

This PR aims to add a toString() override for the generated models. This ensures that whenever the model is printed in the console, it will return the actual data of the model:

'User(name: $name, familyMembers: $familyMembers, family: $family)'

instead of:

Instance of 'User'

The changes are required only when the style is basic and json_serializable. Freezed already has its own implementation of the toString() override so it is not required when the developer uses this style. Therefore, only the {{~ basic_model }} and {{~ serializable_model }} have the new toString method added ({{~ to_string }}).

There have been additional changes inside the pre_gen.dart file to identify when the parameters end. This is needed to ensure that the resulting toString() text does not have a trailing , and is nicely formatted.

Type of Change

LukeMoody01 commented 1 year ago

Hey @ashishbeck ๐Ÿ‘‹

Thanks for opening this PR! It looks great. I will take a closer look later today/this week!