Async/Await - Flutter in Focus

Поделиться
HTML-код
  • Опубликовано: 12 июн 2024
  • This is the fourth video in the Flutter in Focus series on asynchronous coding in Dart. In this episode, learn how to use the async and await keywords with Dart's Futures. They can help you avoid nested callbacks and keep your asynchronous code tight and easy to read.
    For more deep dives on things like Stateless and Stateful widgets, Flutter on iOS, and other advanced topics, check out the other episodes of Flutter in Focus.
    Asynchronous programming: futures & async-await → goo.gle/2XJLPSd
    Flutter in Focus Playlist → goo.gle/FlutterInFocus
    Get started with Flutter → flutter.dev
    Try a Flutter codelab → goo.gl/d3fHPo
    Join the conversation → goo.gl/68oUnb
    This video is also subtitled in Chinese, Indonesian, Italian, Japanese, Korean, Portuguese, and Spanish.
    Subscribe to the Flutter channel → goo.gle/FlutterYT
    #dart #darttopic

Комментарии • 132

  • @tonywright3777
    @tonywright3777 4 года назад +141

    I wish this guy would teach me everything I ever need to know. So clear and clean. Thanks heaps.

    • @agentstona
      @agentstona 3 года назад +1

      i assume you are being sarcastic here......... dude he just over complicated the most simplest of explanations ........ he took 9 minutes to explain something that could be done simply in 5 minutes ........ although 9 minutes is not that bad compared to the 20 minute 1 hour junk now days .......

    • @xynyde0
      @xynyde0 3 года назад +16

      @@agentstona id like to see you try and do a better job then lol

    • @MadeInPython
      @MadeInPython 4 месяца назад

      No he is right. The authors of this channel could benefit by learning "Show and don't tell" which was taught way back in high school. I don't care to be lectured on what it can do. SHOW me what it does in Flutter. Also the docs are quite poor in relation to other languages I've learned. It's scattered across different websites and is not comprehensive with a lot of lessons saying "copy + paste this code here". Many people could do a better job. Just My two cents.@@xynyde0

  • @jaayaustin336
    @jaayaustin336 3 года назад +4

    This channel is teaching me FLutter while helping me understand Javascript better, thanks!

  • @Dhruvam
    @Dhruvam 4 года назад +126

    I am a simple man, I see flutter and I watch the video.

    • @rbp365
      @rbp365 4 года назад +10

      Me too. This is just a Dart video essentially though. Dart is the most awesome language I've ever come across, I've read all the official docs I could get on dart.dev. Actually I've never did this to any language

  • @joannabusoba
    @joannabusoba 4 года назад +2

    Thank you for the series! I hadn't seen this before, glad you have arranged your videos well into a playlist. I'll definitely check it out

  • @aaBeben
    @aaBeben 3 года назад +10

    This man is a good teacher.

  • @i_mwanagenzi
    @i_mwanagenzi 2 года назад +1

    So far, I'm demystifying the entire cloud on asynchronous programming in Flutter. Thanks Flutter team

  • @codingwithmassodpersiancha2100
    @codingwithmassodpersiancha2100 4 года назад +3

    thanks for your efforts , all of you in the flutter team.
    i wish i could use flutter with koltin from day one and still do , but i am beginning to make connections to dart thanks to these series of videos.
    i was wandering the other day in the internals of the flutter api , and was curious how exactly is Row implemented for example and i started to write Row myself . and that helped me to get to know every corner of Row widget. i suggest you shooting videos that talk more about internals. unfortunately being new to Dart , has slowed me digging more inside.
    thanks again and really apperciate what you guys do

  • @kpandian1551
    @kpandian1551 4 года назад +8

    Amazing explanation. Can’t be more simple. You guys rock it. Love your team’s way of teaching in the Simplest language and that’s another reason why like Flutter so much.
    Many many Thanks to you all !

  • @alexblackcat2436
    @alexblackcat2436 2 года назад

    very clear and understadable presentation, thanks!

  • @martinseal1987
    @martinseal1987 4 года назад

    Loved the video, love your explanations can't wait for the next one

  • @souley-mohamedrochsome9678
    @souley-mohamedrochsome9678 Год назад

    Thank you sir, I am struggling to understand this concept and your explanations are very clear 🙏

  • @diegoveloper
    @diegoveloper 4 года назад +1

    Excellent explanation, very useful! Would be great to watch some videos about RenderObjects in another serie !

  • @GamerBizzare
    @GamerBizzare 3 года назад

    I love u man, You saved my life. Thanks Flutter!

  • @gabrielgibeausanchez7
    @gabrielgibeausanchez7 Год назад

    Is it just me or this guy's charisma is through the roof?

  • @hanielbaez5723
    @hanielbaez5723 4 года назад

    Nice video, and amazing easy explanation.

  • @ryujiganaha9645
    @ryujiganaha9645 3 года назад

    Great video. Thank you so much!

  • @d-apps2699
    @d-apps2699 4 года назад

    You are amazing! thank you for this video.

  • @longtimedeveloper6498
    @longtimedeveloper6498 3 года назад

    Outstanding presentation!

  • @PetrosPollakis
    @PetrosPollakis 4 года назад

    This video was very helpful! Thanks Google

  • @garethbeall3674
    @garethbeall3674 4 года назад +1

    Such a clear and well thought out explanation - thank you!

  • @shunjidrahman6860
    @shunjidrahman6860 4 года назад +7

    What I have seen on earth ! 😍
    Dart seems so cool 😮

  • @iwandepee
    @iwandepee 3 года назад

    this man really helps me out (:

  • @orewaayakashikitsune4537
    @orewaayakashikitsune4537 2 года назад

    Im still new to flutter and new to this async topic cuz i haven't started learning javascript, but this representative explains sooooooo very clear 🤯.

  • @colectorcell1871
    @colectorcell1871 4 года назад

    Always waiting for next video

  • @MunirHoque
    @MunirHoque 4 года назад

    I used a lot of Async Await pattern of corutines in Kotlin earlier. While watching this video it seems almost similar, it is very easy to understand.

  • @Raimkhodzhanov
    @Raimkhodzhanov 2 года назад +1

    Thank You! Very interesting!

  • @crgmonroe
    @crgmonroe 4 года назад

    Great explanation!

  • @hdkloh6857
    @hdkloh6857 4 года назад +92

    No activity, no fragments, no XML Layout... Only game of widgets.... I like Flutter.

    • @BugGenerat0r
      @BugGenerat0r 4 года назад +8

      When you play the Game of Widgets, you win, or you go back to Xamarin.

    • @okie9025
      @okie9025 4 года назад +4

      If only there was a markup language, preferably HTML, used to create layouts... Well, one can dream

    • @AnonymousAnonymous-nr8su
      @AnonymousAnonymous-nr8su 4 года назад

      @@okie9025 but html is not markaup language, but some old version of XML DTD.

    • @okie9025
      @okie9025 4 года назад +8

      @@AnonymousAnonymous-nr8su remind me what HTML stands for again?

    • @JoyEnergiser
      @JoyEnergiser 3 года назад +1

      @@okie9025 Ugh html . that's how you will feel about Html once you experience how flutters UI layout works.I felt disgusted that I struggled with it for so long

  • @kleytonstn
    @kleytonstn 4 года назад

    The video is great, flutter is awesome!

  • @mbleftley
    @mbleftley 4 года назад

    Async/Await is awesome! Flutter is awesome!

  • @imbayi
    @imbayi 4 года назад +1

    Broken down so well!

  • @remoteportal
    @remoteportal 4 года назад +4

    Okay, you guys win... I'm wholeheartedly giving up JavaScript; I'm a Dart/Flutter guy now--I'm "all in."

  • @TheBlackManMythLegend
    @TheBlackManMythLegend 4 года назад

    Great Teacher Onizuka!

  • @PelpsRoxXx
    @PelpsRoxXx 4 года назад +7

    Holy shit!! So async and await are just Future's and then's masked! That's awesome, thanks for the enlightening, keep it up, nice videos!

    • @andrewbrogdon558
      @andrewbrogdon558 4 года назад +5

      I know, right? Once you realize that they're just syntax for futures, suddenly async and await are no big deal.

    • @abdallahsani5843
      @abdallahsani5843 4 года назад +1

      @@andrewbrogdon558Hi Andrew, I'm new to async I find it interesting though. My question is, Does the for loop wait for the entire stream to finish before it executes?

  • @frankemeli5918
    @frankemeli5918 4 года назад

    Nice one, would like to see a video on state management with providers.
    I love your videos so much that even when I get notified about a new one on the road, I usually don't have the patience to get home before watching.

  • @medamine194
    @medamine194 3 года назад

    andrew is the best teacher ever Periodt.

  • @JAICHANGPARK
    @JAICHANGPARK 4 года назад

    awesome flutter with Async Await Future Stream

  • @KenrickBeckett
    @KenrickBeckett 4 года назад +1

    "cue word" :) @6:49 Keep up the good work guys!

    • @andrewbrogdon558
      @andrewbrogdon558 4 года назад +3

      On the one hand, I'm sad someone noticed, but on the other hand it means someone made it nearly seven minutes into the video before getting bored and loading a different one. :)

    • @pida9669
      @pida9669 3 года назад

      @@andrewbrogdon558 You are an excellent presenter. Complaining about the slight mispronunciation of a syllable in your presentation is like complaining about a microscopic inclusion (flaw) in a VVS diamond. :-)

  • @Shakl-e
    @Shakl-e 4 года назад

    You are great, thanks!

  • @PabloMorlock
    @PabloMorlock 4 года назад

    For what I saw, I concluded that once I used a Future, thereafter I should return a value of some kind of Future. Is it possible to break that depedency, for instance, read an json, an return an map after decode, instead of Future?

  • @deliriouslee2079
    @deliriouslee2079 3 года назад

    wow,this man looks really kind.

  • @serzen
    @serzen 3 года назад

    I've watched this video n-times and I still getting stuff from it

  • @MasterGKH
    @MasterGKH 3 года назад

    The stream has a mechanism to tell to the "listner" that the stream is end?
    I mean, for example in the code at ~08:00, in the video, when the loop "for" is ended?
    I hope its is clear my question.

  • @hurbangash1302
    @hurbangash1302 2 года назад

    thanks

  • @nimishkhattar2017
    @nimishkhattar2017 2 года назад

    crystal clear

  • @DiazGunturFebrian
    @DiazGunturFebrian 4 года назад

    At 7:59 the parameter should be Stream numbers so that we can for loop? CMIIW

    • @chewie7235
      @chewie7235 4 года назад

      You're wrong.

    • @andrewbrogdon558
      @andrewbrogdon558 4 года назад

      @@basselcheaib Exactly! With await-for, the loop iterates over the values produced by the stream, so there's no need for a list.

  • @TinBuz
    @TinBuz 4 года назад

    Flutter/Dart is a dyslexic coder’s dream

  • @MdSiam-kw5ox
    @MdSiam-kw5ox 2 года назад +1

    Future API is awesome 😍

    • @flutterdev
      @flutterdev  Год назад

      Very awesome, Md! We're excited about the future too 😍
      Have you checked out our Dart codelabs? Catch up here👀: goo.gle/3xjc7Qe

  • @mateusfccp
    @mateusfccp 4 года назад +6

    I still prefer .then syntax.
    Future createData() =>
    _loadFromDisk()
    .then(_fetchNetworkData)
    .then((data) => ProcessedData(data));
    It's clearer for me.

    • @marflage
      @marflage Год назад

      It helps in understanding the code but reduces readability. Not to mention, the then syntax really takes a hit on both readability and understandability when the logic becomes convoluted and there are many nested thens in thens.

  • @meowmeowmeow5332
    @meowmeowmeow5332 4 года назад

    Very nice

  • @Algardraug
    @Algardraug 3 года назад

    Okay, so I'm still a bit confused as to in what thread async functions/tasks execute? If I wait await for some resource intensive task, will my app stutter?

  • @nidafatima5000
    @nidafatima5000 4 года назад

    hi , I need to know exact build apk process for all platform we tried and get success in android -arm64bit only but we need to test all other platforms pls help me.

  • @dasdunetechnologies1695
    @dasdunetechnologies1695 4 года назад

    reverse video 2 and 3 in the list. Future event

  • @pspdito
    @pspdito 4 года назад

    learned a lot of clean code and data structures oh yeaa

  • @aakashjana6225
    @aakashjana6225 4 года назад

    This concept originates from Python which is also a language that executes on a single core of the cpu unlike compiled languages like Java. (Although dart is also compiled)

  • @Parul_Nandwani
    @Parul_Nandwani 4 года назад

    hey team, help me out..I am getting this error when trying to insert data into my SQL database. the error is --- socketException: connection timed out, errno = 110, address = 120.00.0.000, port = 44103. I have added "access control allow origin" in my PHP but still getting this.

  • @jmarms
    @jmarms 4 года назад +2

    I really dig that shirt.

    • @JulianoPenna
      @JulianoPenna 5 месяцев назад

      What does that mean? I know it's California, but what about the "blank region"?

  • @refayetshanto
    @refayetshanto 2 года назад

    Hi, your videos really helped me learn flutter in a very simplistic way. One somewhat related question which will do a big favour to me. Why I can't assign a Future to int. I simply want to assign Future to an int variable. Please help.

    • @marflage
      @marflage Год назад

      You can not assign a Future to a non-Future. While assigning a Future to a variable of type int, you are essentially only assigning an empty box (from the gift analogy from the video on Futures, also talked about in this video) to the variable. When a Future starts getting executed, it first returns an empty box to the calling statement as an indication that the Future has not completed yet. When a Future has completed executing, it returns the actual data or error to the calling function. When you do int i = Future, you are only getting the first return (the empty box) and the int variable accepts no further values; because non-Future variables need instant access to values and thus cannot wait. Now to make the variable wait for the actual useful data, we can use the await keyword before the Future expression. Like so: int i = await Future

  • @_Amilio_
    @_Amilio_ 3 года назад

    How does the await for know that the stream is complete?

  • @bsizeindian3966
    @bsizeindian3966 4 года назад +2

    Where is your button?

  • @karansoni3543
    @karansoni3543 4 года назад

    anyone suggest me how to take a printout of a widget(ID Card Generated by flutter app ) in flutter

  • @codewa7605
    @codewa7605 3 года назад

    is there a way to cancel the callout?

  • @aminebenichou4818
    @aminebenichou4818 3 года назад

    I am getting when calling a function

  • @soroush51
    @soroush51 3 года назад

    if there could be 'else' keyword to execute when try section ran without any errors and successfully(like python) it would be great

    • @marflage
      @marflage Год назад

      Is not the code right after the try-catch block a kind of else for the execution of the program?

  • @Gamex996
    @Gamex996 4 года назад

    1:30 lies, will I had a lot of issues with .then because it gives null and goes on

    • @minma02262
      @minma02262 4 года назад

      Either you are not returning, or your return is null

  • @junior.santana
    @junior.santana 4 года назад

    Ok I understood how to use it but the question I'm struggling is why to use it?
    I have to wait for the disk/network response anyway.
    I mean, what kind of problem I would be solving?

    • @jackma1241
      @jackma1241 4 года назад

      It will help you handle async job in syny way, especially interact with UI code. For example, if you need to load an image from network after clicking a button, it would be messy to use Future API, or even more messy to use a thread like in Java. But in dart, you can create an async method, write both your UI code and blocking operation in it, like show a loading dialog, await image to be loaded, hide loading, using try catch with exception, all in a sync way without blocking UI. Your code would be much more clear.

  • @StEvUgnIn
    @StEvUgnIn 4 года назад +3

    Watch out, Xamarin

    • @crossfade7112
      @crossfade7112 4 года назад

      who actually uses xamarin😂😂

  • @felixtopappz7338
    @felixtopappz7338 4 года назад

    Can flutter be used on rapidApi.com to make calls

  • @kirill4531
    @kirill4531 4 года назад +3

    Yeah, a sequence of multiple "then((){}" looks piled up

  • @roykarseboom9185
    @roykarseboom9185 3 года назад

    Why do you need to mark function with async tag? It's just confusing because functions with Futures without async keyword also run asynchronously... anyway, I like the videos :)

  •  4 года назад

    Hello, do you know how can I list my instagram followers with flutter ? I want to make something on social media with flutter but I dont know how can I use my social media with flutter ?

    • @andrewbrogdon558
      @andrewbrogdon558 4 года назад +1

      Instagram has an HTTP API (at least as far as I can tell), and you can certainly make HTTP requests with Flutter and display the results!

  • @engMark90
    @engMark90 2 года назад

    But there is a difference between then & await, await will not execute the lines after it until resolves, on the other hand "then" will execute the following lines and resolve sometime later then execute the callback.

    • @engMark90
      @engMark90 2 года назад

      I just want to focus on the point that Yes await is a syntactic sugar for nested then, but the following lines after in the same scope will never be executed when using await, however it does when using "then"

  • @johnaldrin5924
    @johnaldrin5924 4 года назад +1

    Cons to using async/await? I think we are being done a disservice by not mentioning when async/await is not the best choice. If I have long running async function will it impact the UI?

    • @rolfhendriks5362
      @rolfhendriks5362 4 года назад

      Async/await does not give you the full power of using futures directly. For example there is no async/await equivalent of Future.wait to spawn several async tasks concurrently and wait for all to finish, optionally failing the entire set of tasks on the first error. Async/await is just a thin layer of syntactic sugar around the normal task of executing one or more asynchronous operations sequentially. Async/await, being syntactic sugar on top of futures, does not actually block execution of a function, so your UI will not be impacted by async/await. So to be clear: an async method actually returns as soon as it encounters an await call, not when the results come in.

  • @hamzacodes2785
    @hamzacodes2785 3 года назад

    which country is on his t-shirt?

    • @JulianoPenna
      @JulianoPenna 5 месяцев назад

      That is California, not a country. But I'd like to know what that "blank region" means.

  • @notanenglishperson9865
    @notanenglishperson9865 2 года назад

    What async* does?

  • @dannykay4919
    @dannykay4919 Год назад

    Nice explanation w/ trivial examples. How about calling async methods from a build context, this is flutter after-all not just dart.. I see odd behavior frequently that doesn't seem in line w/ this explanation..

  • @SalemTech
    @SalemTech 4 года назад

    I think i have a problem relative to this concept i guess!
    I'm trying to push notifications locally in a flutter app
    these notifications are repeated daily at a specific time .. i have four notifications at different four times to be sent but only one is sent !! and the others cancelled i do not know what is the reason but these notifications are sent in an async way
    can you help me ?!
    i'm using the flutter_local_notifications plugin

    • @hehehaha3676
      @hehehaha3676 4 года назад

      You should ask on stackoverflow

  • @davidagyakwa288
    @davidagyakwa288 2 года назад

    this has to be updated for the new isolate update 🤷🏾‍♂️

  • @harry356
    @harry356 2 года назад

    I miss the advantage if you use await on each method call. I don't see an improvement from sychronous coding? Why not old fashioned let the programmer decide if an IO intensive thread should be spawned?

  • @dxvfdfx
    @dxvfdfx Год назад

    as Android developer we need this kind of video explanation of how Kotlin flow works, if anyone has the video link, please share thanks

  • @claudiubele4892
    @claudiubele4892 3 года назад

    "... and the first time I saw them I remember being weirded out"

  • @vballaddict75252
    @vballaddict75252 3 года назад

    "Finally" block executes AFTER the return statement!!! Ouch. I think my old C-oriented mind may need to be reset... :-)

  •  3 года назад

    Forgot to explain how to handle the returned Future. That's the painful bit, IMHO

    • @michaelrogers6935
      @michaelrogers6935 3 года назад

      That was covered in a previous video - the easiest way is to pass it to a FutureBuilder.

  • @reapergrim5324
    @reapergrim5324 2 года назад +1

    Please use black background in future videos , watching this at night hurts .

    • @flutterdev
      @flutterdev  2 года назад +1

      Hi! Thank you very much for the feedback. We have shared your suggestion to our production team 😀

  • @TheCodeWhisperer0o0
    @TheCodeWhisperer0o0 9 месяцев назад

    does anyone gets benefit from these videos?! I mean practicaly and using inside the code, I know that you would get an idea basically.

  • @peruviancode1360
    @peruviancode1360 4 года назад +1

    Using await is most simple 😂😂

  • @sasat0ru
    @sasat0ru 3 года назад

    i thing u can say 'just like javascript' and end the video ;P

  • @keepdream
    @keepdream 4 года назад +1

    please google make a framework that can use html&css&js to produce android and ios application

  • @marduchok
    @marduchok 4 года назад

    Ohio is a state

  • @yangyun6221
    @yangyun6221 Год назад

    Flutter guides make Android courses like amateurs

  • @hackaholic01
    @hackaholic01 Год назад

    Looks so dump, if you wating then there is no asyn here, all are waiting on other, what uses it have,One can load data from disk and do network call, Why to make things complected, Achieving sync call using async, what a noob development here.

  • @heshansandeepa9471
    @heshansandeepa9471 2 года назад +1

    Very nice