List Method .fold() in Dart and Flutter
ฝัง
- เผยแพร่เมื่อ 23 ก.ค. 2024
- In this series, we will learn more about different list methods in #Dart and see how we can use them in #Flutter. In this episode we have a closer look at .fold() method in different list types and see how we can use this method to calculate the total amount of prices in a table in a flutter application.
00:00 - Introduction
00:22 - Example one: forEach and fold method explanation on a list of String
03:40 - Example two: fold method on list of integer
04:14 - Example three: fold method on list of object
05:18 - Overview over the boilerplate code
07:14 - fold method in Text Widget
08:26 - Outro
⭐️⭐️Helpful Ressources ⭐️⭐️
DartPad: dartpad.dev/a64685664fccd0c94...
GitHub Repository: github.com/mt-tadayon/fold_tu...
Tools we use to grow our TH-cam channel
TubeBuddy Review - Manage Your TH-cam Channel Easily
www.tubebuddy.com/flutterexpl...
Our current TH-cam gear
🎙 Samson Mic: amzn.to/324Gpof
📟 Satechi USB-C Adapter: amzn.to/3kUdQ5M
💻 MacBook Pro: amzn.to/3iQ9MBx
📹 Lumix FZ1000: amzn.to/3g7tW8D
⭐️⭐️Follow us ⭐️⭐️
Twitter Mahtab - / mahtab_dev
GitHub Mahtab - github.com/mt-tadayon
Twitter Max - / flutter_exp
Github Max - github.com/md-weber
Homepage - myracledesign.de/blog
⭐️⭐️ Support ⭐️⭐️
If you read this so far, thank you once more. If you like to support us, here are some links that could help us a lot.
Donation via Streamlabs - You are free to donate us a small amount, so we can keep up our work.
flutterexplained.live/
Amazon Affiliate Link - You buy for the same price and I get a small amount of it. This leads to an amazing Flutter book that I can recommend to every beginner of flutter amzn.to/2uOJXON
Great Content ! ✌😁 Keep up the good work
Excelent explanation. Thanks
You are most welcome!
What a great topic ...much love sending to you.
Very nice description of the .fold() method, thank you!
I am glad that it helped you :)
Very nice explanation
awesome !!! Thank you so much (from S.Korea)
You are welcome :)
Thank you so much, you made my day!
You are most welcome :)
Awesome tutorial !! I learnt many things.
Interesting, I didn't knew about this method ! Thanks for the video.
Great I am very happy that it helps you along your way :)
great it helped a lot
Awesome tutorial... I liked it ..
very nice and simple video keep it 👆 👆
Thanks ❤
You are very good teacher :)
good video thanks a lot from spain!!!
Thanks
Thank you
I like how you pronounce Flutter, thank you for your video.
nice channel ⭐keep going plz
Good one !!!
I am glad that you enjoyed it :)
grt & tnx.
Most welcome
well explained 👍
Thank you 🙂
♥️♥️
please need Map Properties in Dart and Flutter
how can I replace an item in a list with another item in the same index? (ie delete an item and place another item in the same place as it was)
If you know the index it is quite easy, you can just overwrite it.
stackoverflow.com/a/63757729/3690032
To find the index you can use methods like indexOf. I hope that helps :)
if you get an error in 2021 about num not being int - simply disable null safety. This is a problem with dart not the code.
Great stuff, thanks Eli :) yes, this was done in a non-null safe environment!
I get error while running this...I think it's a null safety issue...how to resolve please
//Find sum age of all friends and print it.
List myFriends = [
Friend(name: 'Mahtab', age: 18),
Friend(name: 'Sara', age: 25),
Friend(name: 'Mathias', age: 32),
Friend(name: 'Alex', age: 22)
];
int sumAge = myFriends.fold(0, (prev, friend) => prev + friend.age);
print(sumAge);
}