While learning flutter_bloc from bloclibrary website, I had to use a function with the constructor named copyWith()
. Can anyone explain to me what exactly it does?
Usually, copyWith()
creates a clone of the object with provided parameters overridden.
The copywith
function creates a copy of poststate
with some modification so that you don't need to create the whole state again.
The author said in his blog.
"We implemented copyWith so that we can copy an instance of PostState and update zero or more properties conveniently (this will come in handy later )".
For more info, you can read the following document.
https://github.com/felangel/bloc/blob/master/docs/cs/flutterinfinitelisttutorial.md
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With