Closed MohaAmiry closed 4 days ago
Yes applying a hook to a class will always expect the non-nullable type (Location). You can try instead applying the hook to the field, which will the work correctly with the nullable type (Location?).
So:
@MappableClass()
class Person with PersonMappable{
final String name;
@MappableField(hook: LocationHook())
final Location? location;
const Person(this.name, this.location);
}
so to achieve my goal "make every location null if the a specific condition is true", i must use the location hook everywhere i use the location object. right?
yes
for the following code:
Expected Result: i'm expecting to change every Location object to null in case the address is empty.
Actual Result: running the previous code will throw the following exception although the
Person.location
is nullable: