Map Function easy explained: It is the same like a foreach loop This means, for every item in your list do something For example here we have a list with name Quotes. We say with .map that loop/go for each item in this list (here we have 3 strings (be yourself..., "i have nothing.,.." ,"the truth ..." ) and do something. He say for every item in this list give me a text widget back with the value of the item (be yourself... ) i think u know what i mean. The thing is we have now multiple Text widgets and we have to do the .tolist() because this stores all text widgets in a list.
Today is my day 5 in flutter and I am in episode 20 in this series and I came back to 17 again because this is the point where all the confusion started. Up to episode 16, it was quite easy to catch everything. Making a widget tree and adding its properties is now used to for me but making list, passing parameters, map() function is complicated to understand. So I am revising it once again.
I know it's been 3 years since your comment, but .map() is used through many programming languages to iterate over a list. But since it's been this long you probably have learned that already and excel at this :)
Hi I could not resist myself from writting comment, which i generally dont. I just wanted to show gratitude and say thanks for your dedicated efforts towards explaining every minute detail required to grab complete control over flutter. I was roaming around multiple channels rarely hoping for something like this. You are awesome!!!
This is awesome. I have been using Dart for while and watching this tutorial I have a learnt a few useful techniques I can apply for both server backend and web frontent development. Thank you.
Wassup man, another epic video series by the legit goat of this stuff. I legit ha no clue about flutter today had heard all the hype and will end up able to code an app pretty easily after this playlist, it actually strikes me so much how similar it is to HTML and JS really and then flexbox is thrown in for good measure it's an awesome framework but as always your explanations are top-notch. Cheers 👌🍻
All I have is Thankyou for now. Love your videos and your teaching skills. You earned a subscriber. Also if I end up making an app for a client some amount is going towards your patreon.
hello sir! Big Fan! I am stuck in this part of code. where quotes.map has red line error. the line quotes is underlined red. Please help me. just a beginner and i am getting addicted of your teaching. children: quotes.map((quote) { return Text(quote); }).toList() the line quotes is underlined red. I haved checked possibilites of mistakes and check whether i not defined quotes but yes! code are same exact of yours.
Hello i had this error """ The element type 'List' can't be assigned to the list type 'Widget'.dartlist_element_type_not_assignable""" i had squarebrackets that affected my code ===> children: [ quotes.map ] , I want to Keep those brackets Meaning you can not wrap a list in a list Solution : you can use a separator which is ===> ... so the code will be : children: [ ...quotes.map((e) => Text(e)).toList(), ],
if you are facing the error: The constructor being called isn't a const constructor. Try removing 'const' from the constructor invocation. just remove the const before Scaffold, it is written automatically by the code editor
How do I become a member of the net ninja community, also when I save after putting in the map function I dont get the same orientation for the quotes, mine a one after the next and yours are in paragraph style one below the next
Some quotes to add to your list: "You get in life what you have the courage to ask for.", "People do not decide their futures. They decide their habits and their habits decide their futures.", "Every action you take is a vote for the type of person you wish to become.", "Life isn't about finding yourself. Life is about creating yourself.", "The moment where you live right now is where everything happens."
FROM api.flutter map method Iterable map( T toElement( E e ) ) The current elements of this iterable modified by toElement. Returns a new lazy Iterable with elements that are created by calling toElement on each element of this Iterable in iteration order. The returned iterable is lazy, so it won't iterate the elements of this iterable until it is itself iterated, and then it will apply toElement to create one element at a time. The converted elements are not cached. Iterating multiple times over the returned Iterable will invoke the supplied toElement function once per element for on each iteration. Methods on the returned iterable are allowed to omit calling toElement on any element where the result isn't needed. For example, elementAt may call toElement only once. Equivalent to: Iterable map(T toElement(E e)) sync* { for (var value in this) { yield toElement(value); } } Example: var products = jsonDecode(''' [ {"name": "Screwdriver", "price": 42.00}, {"name": "Wingnut", "price": 0.50} ] '''); var values = products.map((product) => product['price'] as double); var totalPrice = values.fold(0.0, (a, b) => a + b); // 42.5. Implementation Iterable map(T toElement(E e)) => MappedIterable(this, toElement);
Hey, I'd really appreciate it if someone could help me out with this/point me in the right direction. Say I want to create a list of widgets that references data from two different lists. How would I do that? It seems the map function is only good for mapping elements from one list onto one list of widgets.
i am facing a issue here i cant get the list by just saving it or by fast reloading it whenever i change some thing in the list i need to rebuild the app and yes i have my scaffold in the build(){---} anyone knows what could be the issue
children: quotes.map((quote) => Text(quote)).toList() Why don't we use "quotes" in the map, our List name is "quotes" not "quote", So why we use "quote" in the map ???
'Be yourself; everyone else is already taken',
'I have nothing to declare except my genius',
'The truth is rarely pure and never simple'
lol thanks
thanks mathias
@@prenom_nom no problem hope you are doing great with trying to learn flutter
@@prenom_nom mdr c'est quoi ce Nom et ce Prénom ahahha Love it !
God bless you!
You're Amazing buddy. If only school curriculum were like this and teachers were like you world could be a better place.
Total agree. Content delivery is extremely good. He is just perfect.
Thank you! I watched 16 videos in a row then slept 2 hours & here I'm in the 17th, Gonna finish the this playlist today.
Awesome! :D
@@NetNinja please make course for intermediate or advance level in flutter ..
Map Function easy explained:
It is the same like a foreach loop
This means, for every item in your list do something
For example here we have a list with name Quotes.
We say with .map that loop/go for each item in this list (here we have 3 strings (be yourself..., "i have nothing.,.." ,"the truth ..." ) and do something.
He say for every item in this list give me a text widget back with the value of the item (be yourself... ) i think u know what i mean.
The thing is we have now multiple Text widgets and we have to do the .tolist() because this stores all text widgets in a list.
Nicely related!! Just to add, it returns a iterable(Collection) which we convert to anather type of iterable called Lists by using toList() function
Coming from web dev after I got used to the oop patterns everything just clicked.
Today is my day 5 in flutter and I am in episode 20 in this series and I came back to 17 again because this is the point where all the confusion started. Up to episode 16, it was quite easy to catch everything. Making a widget tree and adding its properties is now used to for me but making list, passing parameters, map() function is complicated to understand. So I am revising it once again.
I know it's been 3 years since your comment, but .map() is used through many programming languages to iterate over a list. But since it's been this long you probably have learned that already and excel at this :)
@@motodankz4838 Thanks for your comment I learned something new
@@motodankz4838 well, I know c, c++, java, c# and lua. Yet, I never used map() fun or never seened it before.
LMAO
From Malaysia with love to the greatest teacher of programming, Shaun Pelling.
Hi
I could not resist myself from writting comment, which i generally dont. I just wanted to show gratitude and say thanks for your dedicated efforts towards explaining every minute detail required to grab complete control over flutter. I was roaming around multiple channels rarely hoping for something like this. You are awesome!!!
“Be yourself; everyone else is already taken.”
- Oscar Wilde
Another point for me!
The widgets he uses in this video:
- StatefulWidget{}
- Scaffold()
- AppBar()
- Text()
- Column()
I just want to say.. this is the best video on youtube which explains Map in flutter... YOU ARE THE BEST ..
Thank you so much 😀
Man....... those tutorials are just perfect. Probably the best tutorials I have ever follow on the internet.
Thousands thanks
As a JS dev, I'm really happy that we can use map as well. Even the syntax are alike.
Amazingly taught... love your series man !! Please never stop i will watch em all..
Third quote is by Reymond Reddington from The Blacklist. Bonus points for me, i hope. :D
Haha - 5 Ninja points!
bro season 9s dropping soon
This is awesome. I have been using Dart for while and watching this tutorial I have a learnt a few useful techniques I can apply for both server backend and web frontent development. Thank you.
Thank you for explaining in a simple way
So simple when you explain! Awesome!
Wassup man, another epic video series by the legit goat of this stuff. I legit ha no clue about flutter today had heard all the hype and will end up able to code an app pretty easily after this playlist, it actually strikes me so much how similar it is to HTML and JS really and then flexbox is thrown in for good measure it's an awesome framework but as always your explanations are top-notch. Cheers 👌🍻
Glad you enjoyed it! :)
Your voice is great, your lessons is great and you really help me into this course. Thank you so much, I will finish this course to the final video.
All I have is Thankyou for now. Love your videos and your teaching skills. You earned a subscriber. Also if I end up making an app for a client some amount is going towards your patreon.
Always awesome all the way from react, Vue and to this..never let done!!
man you are truely amazing i would like to express my gratitude for this series by clicking on the ads and will try to increase your revenue
hello sir! Big Fan! I am stuck in this part of code.
where quotes.map has red line error. the line quotes is underlined red. Please help me.
just a beginner and i am getting addicted of your teaching.
children: quotes.map((quote) {
return Text(quote);
}).toList()
the line quotes is underlined red. I haved checked possibilites of mistakes and check whether i not defined quotes but yes! code are same exact of yours.
body: Column(
children: [...Quotes.map((e) =>
Text(e)
)
],
),
Wow maaaan, you deserve an Oscar award actually, i have never found a tutorial like this, THIS SH**** IS EPIC!!!
Amazing skills of simplifying things!! Keep going :)
I never understood map() before watching this video, thanks buddy..
Thank You Sir You are Really a Pro NINJA I want to become Ninja like You hope one day I will IA. Much Love and respect From Pakistan
thank you. you are the best teacher
Hello i had this error """ The element type 'List' can't be assigned to the list type 'Widget'.dartlist_element_type_not_assignable"""
i had squarebrackets that affected my code ===> children: [ quotes.map ] , I want to Keep those brackets
Meaning you can not wrap a list in a list
Solution :
you can use a separator which is ===> ...
so the code will be :
children: [
...quotes.map((e) => Text(e)).toList(),
],
ty
thanx
Can you write more details through it?
Shaun, you are the best! do you have a plan to publish a complete course for Flutter App development in Udemy or somewhere ?
I am thinking about this, but it will probably be later in the year around Autumn if I do.
your explaining is amazing :D ,, very easy to understand even for the complex part.. absolutely subsribe for sure
Awesome, thank you! 😃
so... Map essentially the same as foreach? or am i getting it wrong
This course is simply amazing..........
Perfect tutorial, thanks a lot!
if you are facing the error:
The constructor being called isn't a const constructor.
Try removing 'const' from the constructor invocation.
just remove the const before Scaffold, it is written automatically by the code editor
How do I become a member of the net ninja community, also when I save after putting in the map function I dont get the same orientation for the quotes, mine a one after the next and yours are in paragraph style one below the next
So basically a for loop. Pretty cool!
The Best 35 Videos on Flutter (:
you are awesome ninja!!!
Some quotes to add to your list:
"You get in life what you have the courage to ask for.",
"People do not decide their futures. They decide their habits and their habits decide their futures.",
"Every action you take is a vote for the type of person you wish to become.",
"Life isn't about finding yourself. Life is about creating yourself.",
"The moment where you live right now is where everything happens."
thank you so much for your effort mr ninja
FROM api.flutter
map method
Iterable map(
T toElement(
E e
)
)
The current elements of this iterable modified by toElement.
Returns a new lazy Iterable with elements that are created by calling toElement on each element of this Iterable in iteration order.
The returned iterable is lazy, so it won't iterate the elements of this iterable until it is itself iterated, and then it will apply toElement to create one element at a time. The converted elements are not cached. Iterating multiple times over the returned Iterable will invoke the supplied toElement function once per element for on each iteration.
Methods on the returned iterable are allowed to omit calling toElement on any element where the result isn't needed. For example, elementAt may call toElement only once.
Equivalent to:
Iterable map(T toElement(E e)) sync* {
for (var value in this) {
yield toElement(value);
}
}
Example:
var products = jsonDecode('''
[
{"name": "Screwdriver", "price": 42.00},
{"name": "Wingnut", "price": 0.50}
]
''');
var values = products.map((product) => product['price'] as double);
var totalPrice = values.fold(0.0, (a, b) => a + b); // 42.5.
Implementation
Iterable map(T toElement(E e)) => MappedIterable(this, toElement);
Best Tutorial Ever In UA-cam
The argument type 'Iterable' can't be assigned to the parameter type 'List'. this error when i use map function.
children: mylist.map((e) => Text(e),)).toList(),
You have to add the toList() method like the answer above.
Do you have a Udemy project? I would like to buy it, or just donate.
When i added the list of quotes in the first class which extends Stateful widget, then the program wasn't working. But why?
A strange thing I noticed: when using lambda it seems hot-reload sometimes fails to print the quotes, then when I reload it again it works.
If we want to take first sentence from list...... What should we do????????
We can understand from you that why UK run the World, he is great!
Amazing you deserve 10M subscribers 😍😍😍
awesome sir
Doesn’t .map function return a List object itself as in JavaScript?
so map is basicly a function that when using in list, it cycles through all items in list and for each item of the list it's gonna perform a function
@8:31 shouldn't it be Text('$quote')?
Your videos are the best !
Thanks so much! I did exactly like video, all very well! New subs here. 😁
Awesome! Thank you!
Thank you for sharing the video
No problem Isra! Thanks for watching :)
can we put a list inside a row?
Amazing tutorial.
brilliant tutorial
You are really addictive !!
Can we do the same for SliverList in place of Column?
K it's do-able.
This is the hardest one to understand
Hey, I'd really appreciate it if someone could help me out with this/point me in the right direction. Say I want to create a list of widgets that references data from two different lists. How would I do that? It seems the map function is only good for mapping elements from one list onto one list of widgets.
another great one mate
why can't we use "forEach' in place of map?
keep up the good work!
What if i want different widgets, not just Text
Love these tutorials. :D
Thank You !
Took a while to complete this video using Git
Thank you so much
i am facing a issue here i cant get the list by just saving it or by fast reloading it whenever i change some thing in the list i need to rebuild the app and yes i have my scaffold in the build(){---} anyone knows what could be the issue
i have also tried using the Github code and the output is the same i always need to rebuild to get the Updated list
man you are the best 👌🏾
what a video i love you man
Isn't "The truth is rarely pure and never simple" Oscar Wilde too? 'The Importance of being Earnest', Act 1, Algernon
amazing mate
What would I do without you !
Rather than deleting test file u could have simply rename MyApp() to QuoteList () lol
Thaaanks
Add 3 dots '...' before Quotes.map( ) function to work properly!
...quotes.map((quote){
return Text (quote);
}).toList( ),
no?
body: Column(
children: [...Quotes.map((e) =>
Text(e)
)
],
),
thanks!!
hi am getting error when i run flutter doctor
in the android tool chain part
The people who have disliked his videos are our college Professors
Could someone here explain me in simple words... how the map works here...
children: quotes.map((quote) => Text(quote).toList(),
Thanks in advance....
i am not completely sure but this is probably a syntax of dart in which you can represent a function that just returns something with this syntax.
7:08 map
perfonalist!
like before start the video for the best
am I the only one lost in here? I watched this video twice but I'm a little bit lost in map function... thanks any way a GOD bless u
Shwan Agha same
thanks for the video, but this is the ugliest way to use loops. as a programmer I like using for loops
I agree I love for loops - How would you write that code?
The second one seems like something Jeremy Clarkson will say
children: quotes.map((quote) => Text(quote)).toList()
Why don't we use "quotes" in the map, our List name is "quotes" not "quote", So why we use "quote" in the map ???
Im pretty sure its because you are creating a new tag or whatever which is quote, and then referencing it
love the Oscar quotes
"We have a preview now which is just a black screen of doom" XD
I don't get it why would someone dislike this video
children: [for (var i in quotes) Text(i)] i think this is easier to remember :P
I'm tired of Grey.
Thank you for your hard work!
thank you so much