List Method .forEach() in Dart & Flutter

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ก.ค. 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 .forEach() method in different list types and see how we can use this method to change the background color of a ListTile in a flutter application.
    00:00 - Introduction
    00:23 - Example one: forEach method explanation on a list of String
    01:55 - Example two: forEach method on list of integer
    02:64 - Example three: forEach method on list of object
    03:53 - Overview over the boilerplate code
    05:20 - forEach method in onPressed method
    06:25 - Outro
    ⭐️⭐️Helpful Ressources ⭐️⭐️
    DartPad: dartpad.dev/1f6d7019fb38072d3...
    GitHub Repository: github.com/mt-tadayon/foreach...
    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

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

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

    From someone who has very little experience of flutter and dart I just wanted to leave a comment here saying this was really helpful for me. You explained everything in details (including how to iterate in dart and what arguments it take) and went over everything step by step which is a 100x times better than someone going over some code snippets. Please do keep up making videos like this 😊

  • @darul-asar381
    @darul-asar381 2 ปีที่แล้ว

    This is one of the best Dart lessons, there are many teachers, but few can explain complex stuff in an easy way.

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

    This Kind of teaching is really great! Please keep them creating videos like this ❤

  • @dhanniekristanto
    @dhanniekristanto 4 ปีที่แล้ว +1

    very concise. Thanks. I'm a little confused with the randomized color. Didn't know that hex code is a type of int.

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

    Mind blowing tutorial and explaining the method is tremendous. I think you are the best i fouund for explaining in such a simple and a nice way. Please create a series on Other more and more subject and also if possible please make a series on Flutter APP to connect with a SQL data base by creating our own Rest API. Thank you very very much for providing such a nice tutorial videos.

  • @alial-nuaimi2695
    @alial-nuaimi2695 3 ปีที่แล้ว +2

    everyone can be a coder but it's difficult to be a teacher! GREAT VIDEO

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

    Best and simple explanation

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

    thank you so much 🥺

  • @ekkhitty4175
    @ekkhitty4175 4 ปีที่แล้ว +1

    Thank you.

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

    List method... clear 👍

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

    Muito bom!

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

    Good a query if What is inside the forEach is a nested class as it would work to display the data

  • @Superturisto
    @Superturisto 4 ปีที่แล้ว +1

    Hi , Thank you very much ,that was helpful . Could you please make something like that about Stream methods as well ?

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

      Hello Superturisto and thanks a lot for your feedback. This is an amazing idea, we will definitely consider it and will create tutorials for them. :)

  • @danieldantas1309
    @danieldantas1309 4 ปีที่แล้ว +1

    Hello! Thank you so much for this video! Only one doubt remains: When we call the forEach method, we put a word into the parenthesis, as you did on minute 1:31 with the word "name". My doubt is: Is this word alleatory? Can we choose whatever we want? Thanks so much!

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

      Great that you liked our video :). The'name' in that case is a parameter inside the foreach callback. The idea is to name the parameter whatever you like but the list we are iterating over is called 'names'. Therefore it makes sense to call the element inside 'name'. I hope that helps and make sense!

    • @danieldantas1309
      @danieldantas1309 4 ปีที่แล้ว +1

      @@FlutterExplained Make sense! Thank you very much

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

    how to removed duplicates using forEach from a list

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

    What is the difference between map and for each ?

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

      While map creates a new array with the results of calling a provided function on every element in the calling array. forEach executes a provided function once for each array element.
      If you have a List of integers and want a list of strings you would use map. If you want to print every element in a List you would use forEach.

  • @takiuddin93
    @takiuddin93 4 ปีที่แล้ว +1

    how'd I add new data to the list?

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

      The easiest way to add a new element to a list is by using the add function. api.dart.dev/stable/2.8.4/dart-core/List/add.html
      An example can be found here: github.com/mt-tadayon/fold_tutorial/blob/61f1de522470892a7cc22ccd57551fb10caa6a02/lib/dashboard.dart#L66

    • @takiuddin93
      @takiuddin93 4 ปีที่แล้ว +1

      @@FlutterExplained that's a very quick reply and thank you, I was instantly able to fix my issues..

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

      That is fantastic to hear, glad that I could help :)

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

    line 46
    friend.color = (Random().nextDouble() * 0xFFFFFFFF).toInt();
    same shuffle method? or no?