Was able to complete this course today. I must say, I have learned a whole new thing about collections. This is really an eye-opener course. Thank you so much Mr. Vandad.
@VandadNP when you add the getter to protect the _siblings list in the Person class, returning UnmodifiableListView, doesn't it just stop the outside from modifying the list when accessing via .siblings? It can still modify the actual list in _siblings just as before? It seems it's still as vulnerable to edits from the outside as before. Or am I missing something?
print('---add to dictionary----'); const food = { 'name': 'hello', 'age': 28, }; final result = {...food}.addAll({'other': 9}); print(result); //This expression has a type of 'void' so its value can't be used...why it gives me error although I followed the same code: at 1:44:00
To deep copy a list of maps you can first map the list, and then for every map in the list, create a copy of it using Map.from(), like this => yourList.map((map) => Map.from(map)).toList();
@VandadNP Thanks. So the spread operator has use in only simple things then. I'm learning Dart for a month and I was shocked that there are no option to pass a variable to a function by reference in order to modify the original object and when I've just come to terms with this fact I noticed (after searching for a bug in my code for several minutes) that lists and maps break out of the schema and they are not passed as copies but references. Unfortunately there's no deep copy option in the language so I had been using json.decode.json.encode(list)) to serialize and deep copy this way, but the map seems to be working more elegantly. Thanks again.
In 1:47:08 I fixed the code like this: void main(List args) { final string = 'abracadabra'; var result = { for (final char in string.split('')) 'abc'.contains(char) ? null : char }..removeAll([null]); var result2 = result.toList(); print(result2); } Unfortunatelly, I cound't find a way to apply the rest of chaining methods. It only applies removeAll, but not the rest. And it also forces me to create a "result2" variable, I coudn't even mutate the same "result" variable. I wonder if this is a bug from the dart language that should be corrected by the google team, or wether there is another way.
I was able to get it to work this way: final string = 'abracadabra'; var allExceptAbc = { for (final char in string.split('')) 'abc'.contains(char) ? null : char }.whereType().toSet(); print(allExceptAbc);
simply do this: final string = 'abracadabra'; final allExceptAbc = { for (final char in string.split('')) if (!'abc'.contains(char)) char }; print(allExceptAbc);
first of all thank you for your work and I hope you lead a blessed life. I have a question on the codeActionOnSave, so i added the entries on json user setting but i get the error "end of the file expected when I place them outside {} of the default entries, but when I place them inside the default entries nothing happens. what did I do wrong and ty. "[dart]": { "editor.codeActionsOnSave": { "quickFix.add.required": true, "quickFix.add.required.multi": true, "quickFix.create.constructorForFinalFields": true, "quickFix.create.constructorForFinalFields.multi": true, "quickFix.remove.thisExpression:": true, "quickFix.remove.thisExpression.multi": true }, "editor.formatOnSave": true, "editor.formatOnType": true }
I have watched so many courses but this course is a super game changer. Thank you sir for providing us great course
Congratulations, this is a course that truly teaches and not empty tutorials, I'm learning a lot.
With every dart lecture you are winning my heart. Thank you Sir for making videos in great details❤❤❤
This is life changing course. Thank you sir for providing us great content🤗.
It's my pleasure 🤗
Great tutorial for Dart collections. I'm at the half of the video and already loving it - the details, examples, straight to the point approach,...
Was able to complete this course today. I must say, I have learned a whole new thing about collections. This is really an eye-opener course. Thank you so much Mr. Vandad.
if this is crash course then i can't imagine the length of full course.... thank you much sir such a great video.
High quality as always!! Thanks!!
Sir, you are a legend!
Wow, thanks! and you too 🚀
Thank you Vandad!
@VandadNP when you add the getter to protect the _siblings list in the Person class, returning UnmodifiableListView, doesn't it just stop the outside from modifying the list when accessing via .siblings? It can still modify the actual list in _siblings just as before? It seems it's still as vulnerable to edits from the outside as before. Or am I missing something?
sir you are Great
Thank you and you too 😊
thanks
Keep going bro
Wish I could like this video more than once
just like it 3 times bro.
I fuckin love you man ! Thanks
print('---add to dictionary----');
const food = {
'name': 'hello',
'age': 28,
};
final result = {...food}.addAll({'other': 9});
print(result); //This expression has a type of 'void' so its value can't be used...why it gives me error although I followed the same code: at 1:44:00
The spread operator is great but what about more complicated things like lists of maps? How to copy those? Is the spread operator still usefil?
To deep copy a list of maps you can first map the list, and then for every map in the list, create a copy of it using Map.from(), like this => yourList.map((map) => Map.from(map)).toList();
@VandadNP Thanks. So the spread operator has use in only simple things then. I'm learning Dart for a month and I was shocked that there are no option to pass a variable to a function by reference in order to modify the original object and when I've just come to terms with this fact I noticed (after searching for a bug in my code for several minutes) that lists and maps break out of the schema and they are not passed as copies but references. Unfortunately there's no deep copy option in the language so I had been using json.decode.json.encode(list)) to serialize and deep copy this way, but the map seems to be working more elegantly. Thanks again.
How to show the error message on the right side within line???? All error and suggestion are on the bottom
In 1:47:08 I fixed the code like this:
void main(List args) {
final string = 'abracadabra';
var result = {
for (final char in string.split('')) 'abc'.contains(char) ? null : char
}..removeAll([null]);
var result2 = result.toList();
print(result2);
}
Unfortunatelly, I cound't find a way to apply the rest of chaining methods. It only applies removeAll, but not the rest. And it also forces me to create a "result2" variable, I coudn't even mutate the same "result" variable. I wonder if this is a bug from the dart language that should be corrected by the google team, or wether there is another way.
I was able to get it to work this way:
final string = 'abracadabra';
var allExceptAbc = {
for (final char in string.split('')) 'abc'.contains(char) ? null : char
}.whereType().toSet();
print(allExceptAbc);
simply do this:
final string = 'abracadabra';
final allExceptAbc = {
for (final char in string.split(''))
if (!'abc'.contains(char)) char
};
print(allExceptAbc);
One thing that I didn't understand was: When to use List and when to use Iterable?
I want my bag of candies that I said yes too 😜
Mature dart tutorial
first of all thank you for your work and I hope you lead a blessed life.
I have a question on the codeActionOnSave,
so i added the entries on json user setting but i get the error "end of the file expected when I place them outside {} of the default entries, but when I place them inside the default entries nothing happens. what did I do wrong and ty.
"[dart]": {
"editor.codeActionsOnSave": {
"quickFix.add.required": true,
"quickFix.add.required.multi": true,
"quickFix.create.constructorForFinalFields": true,
"quickFix.create.constructorForFinalFields.multi": true,
"quickFix.remove.thisExpression:": true,
"quickFix.remove.thisExpression.multi": true
},
"editor.formatOnSave": true,
"editor.formatOnType": true
}