Replies: 1 comment 2 replies
-
|
Hi @phamquoctrongdev, you can optimize the way you update regions = regions.map((region) => region.copyWith(
counties: region.counties.map((county) => county.copyWith(
districts: county.districts.map((district) =>
district.id == '2' ? district.copyWith(name: 'New district') : district
).toList(),
)).toList(),
)).toList(); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Assume I have 3 freezed classes: (skip syntax error please).
Currently, if I would like to update the
Districtwithid=2, I do:Is this the best way to update adeeply nested object in List?
Is there a shorter way to implement this?
@rrousselGit Sorry for mention.
Thank you so much!
Beta Was this translation helpful? Give feedback.
All reactions