Flutter:Dart copyWith method

preview_player
Показать описание
Flutter and Dart copyWith method and how it works.
copyWith() method creates immutable object. Which means you can not destroy or edit the object you create. One of the way to understand why it's immutable, you can understand from the constructor modifer const. If you put const modifier, it becomes immutable which means you won't be able to edit it.

Another thing why copyWith() method returns immtuable object is that you see, all of our fields are final. If all the fields are final and constructor has const modifier, the return object must be immutable.

Immutable objects are safe and easy to pass around. If you pass around immutable object, you don't need to worry that, they will be editted.

Because nobody can edit them. So this is very safe for saving or recoding or storing data. That's how our chat state also becomes safe.
Course that uses copy with method extensively
Рекомендации по теме
Комментарии
Автор

Thank you for the wonderful video sir it is very helpful for me and my team, Thanks again sir
I love your way of teaching sir thank you

pravinprince
Автор

Hi, thank you for your video series :) As for continuation of Bloc topics could you enlighten any examples of usage blocWhen vs BlocSelector and if there was covered 'lazy' flag, then maybe 'listen' property aswell? :)

adaada