List Method .reduce() in Dart and Flutter

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ค. 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 the #reduce method in different list types in Dart. Additionally, we will see how we can use this method to calculate the total expenses in a flutter application and show it in a DataTable. Also, we will calculate the rest budget with the fold method in our flutter application.
    00:00 - Introduction
    00:34 - Example one: reduce method explanation on a list of integer
    01:40 - Example two: reduce method on the list of String
    02:15 - Example three: reduce method on a list of object
    03:20 - Overview over the boilerplate code
    04:00 - Tasks explanation
    04:22 - Reduce method to calculate the total expenses in the Flutter app
    06:00 - Fold method to calculate the rest budget in the Flutter app
    07:00 - Outro
    ⭐️⭐️Helpful Ressources ⭐️⭐️
    DartPad: dartpad.dev/ba2544c47094780e0...
    GitHub Repository: github.com/mt-tadayon/reduce_...
    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 - flutter-explained.org/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 BuyMeACoffee - www.buymeacoffee.com/flutterexp
    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

ความคิดเห็น • 23

  • @h3w45
    @h3w45 3 ปีที่แล้ว +1

    Well done.

  • @azackmatoff2570
    @azackmatoff2570 3 ปีที่แล้ว +2

    You have the best tutorials for flutter and dart! Awesome! Thanks a lot

    • @FlutterExplained
      @FlutterExplained  3 ปีที่แล้ว

      You are very welcome :) I hope it helps you.

  • @zimani7g473
    @zimani7g473 2 ปีที่แล้ว +1

    Thanks a lot

  • @longtimedeveloper6498
    @longtimedeveloper6498 3 ปีที่แล้ว +1

    Very well done, thank you!

  • @fluttercourseshok1270
    @fluttercourseshok1270 2 ปีที่แล้ว

    رائع ومبدع لايك كبير

  • @oxglowinc.1614
    @oxglowinc.1614 3 ปีที่แล้ว +1

    Good job! Clearly explained.

  • @vatan2578
    @vatan2578 3 ปีที่แล้ว +1

    Thank you very much for your work. Your expression is excellent. I wish you and your loved ones health and happiness.

  • @usama_khalid
    @usama_khalid 2 ปีที่แล้ว +1

    This video is extremely helpful. Thank you

  • @vinayreddypulagam
    @vinayreddypulagam 3 ปีที่แล้ว +1

    thank q

  • @rv9570
    @rv9570 2 ปีที่แล้ว

    Please create a series on Map like this list tutorial. Thanks for great explanation.

  • @athulkrishnadiyil1735
    @athulkrishnadiyil1735 3 ปีที่แล้ว +1

    nicely explained....

  • @LiranMansur
    @LiranMansur 3 ปีที่แล้ว +1

    These vids are gold 🥇
    Question:
    Is there a method to group list\map by value?
    i.e grouping the list below by brand...
    [Car(brand: 'BMW', color: Red), Car(brand: 'BMW', color: Black), Car(brand: 'Mercedes', color: White)]

    • @billyjoseph3540
      @billyjoseph3540 3 ปีที่แล้ว +1

      I'd go with
      myList.map((e) => e.brand).toSet().toList();

    • @FlutterExplained
      @FlutterExplained  3 ปีที่แล้ว +1

      If you want to get a list of different brands from myList without repeating the same brands, this is exactly the right solution. And if you want to create a list of all brands, you don't need toSet().
      I create a Gist for that and hope it can help you :)
      dartpad.dev/f9fcc3cd62b67e7304a7b6a5589f416f

    • @LiranMansur
      @LiranMansur 3 ปีที่แล้ว +1

      @@FlutterExplained Thanks for the thorough reply you are awesome ❤
      I'm sorry but I think my example was misleading.
      Let's say I have a shopping list:
      [
      Cart(date: 19/8/2020, item: shirt, price: 20),
      Cart(date: 19/8/2020, item: glasses, price: 10),
      Cart(date: 18/8/2020, item: pants, price: 30),
      Cart(date: 18/8/2020, item: shirt, price: 15),
      Cart(date: 17/8/2020, item: hat, price: 5)
      ]
      My question is how to I group the list by date to get the total cart amount for a single date?
      Result:
      19/8/2020 > total price: 30 (2 items)
      18/8/2020 > total price: 45 (2 items)
      17/8/2020 > total price: 5 (1 item)

    • @FlutterExplained
      @FlutterExplained  3 ปีที่แล้ว +2

      No worries, it's fine. I create a new DartPad with the solution for you. I hope it can help you. :)
      DartPad Link: dartpad.dev/9f6d129ef8b35551575254fb65830cf5
      BTW for practicing dart algorithms, I can highly recommend you the exercism. This helped me a lot. exercism.io/my/tracks/dart

  • @nurizzatimauladabdulrahim4634
    @nurizzatimauladabdulrahim4634 3 ปีที่แล้ว

    hi, I've watched your video th-cam.com/video/wngN0vLYwlw/w-d-xo.html and there is something that I don't understand. I have an assignment for dart that I need to do subtraction. input: 21, 23, 12, 45, 39, 40. I was asked to split the input into a list by using .split() function. how do I do the subtraction for all the inputs in the list? I couldn't find any ways possible yet. thank you! :)