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
I wish this guy would teach me everything I ever need to know. So clear and clean. Thanks heaps.
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 .......
@@agentstona id like to see you try and do a better job then lol
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
This channel is teaching me FLutter while helping me understand Javascript better, thanks!
I am a simple man, I see flutter and I watch the video.
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
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
This man is a good teacher.
So far, I'm demystifying the entire cloud on asynchronous programming in Flutter. Thanks Flutter team
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
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 !
very clear and understadable presentation, thanks!
Loved the video, love your explanations can't wait for the next one
Thank you sir, I am struggling to understand this concept and your explanations are very clear 🙏
Excellent explanation, very useful! Would be great to watch some videos about RenderObjects in another serie !
I love u man, You saved my life. Thanks Flutter!
Is it just me or this guy's charisma is through the roof?
Nice video, and amazing easy explanation.
Great video. Thank you so much!
You are amazing! thank you for this video.
Outstanding presentation!
This video was very helpful! Thanks Google
Such a clear and well thought out explanation - thank you!
What I have seen on earth ! 😍
Dart seems so cool 😮
this man really helps me out (:
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 🤯.
Always waiting for next video
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.
Thank You! Very interesting!
Great explanation!
No activity, no fragments, no XML Layout... Only game of widgets.... I like Flutter.
When you play the Game of Widgets, you win, or you go back to Xamarin.
If only there was a markup language, preferably HTML, used to create layouts... Well, one can dream
@@okie9025 but html is not markaup language, but some old version of XML DTD.
@@AnonymousAnonymous-nr8su remind me what HTML stands for again?
@@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
The video is great, flutter is awesome!
Async/Await is awesome! Flutter is awesome!
Broken down so well!
Okay, you guys win... I'm wholeheartedly giving up JavaScript; I'm a Dart/Flutter guy now--I'm "all in."
Great Teacher Onizuka!
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!
I know, right? Once you realize that they're just syntax for futures, suddenly async and await are no big deal.
@@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?
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.
andrew is the best teacher ever Periodt.
awesome flutter with Async Await Future Stream
"cue word" :) @6:49 Keep up the good work guys!
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. :)
@@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. :-)
You are great, thanks!
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?
wow,this man looks really kind.
I've watched this video n-times and I still getting stuff from it
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.
thanks
crystal clear
At 7:59 the parameter should be Stream numbers so that we can for loop? CMIIW
You're wrong.
@@basselcheaib Exactly! With await-for, the loop iterates over the values produced by the stream, so there's no need for a list.
Flutter/Dart is a dyslexic coder’s dream
Future API is awesome 😍
Very awesome, Md! We're excited about the future too 😍
Have you checked out our Dart codelabs? Catch up here👀: goo.gle/3xjc7Qe
I still prefer .then syntax.
Future createData() =>
_loadFromDisk()
.then(_fetchNetworkData)
.then((data) => ProcessedData(data));
It's clearer for me.
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.
Very nice
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?
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.
reverse video 2 and 3 in the list. Future event
learned a lot of clean code and data structures oh yeaa
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)
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.
I really dig that shirt.
What does that mean? I know it's California, but what about the "blank region"?
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.
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
How does the await for know that the stream is complete?
Where is your button?
anyone suggest me how to take a printout of a widget(ID Card Generated by flutter app ) in flutter
is there a way to cancel the callout?
I am getting when calling a function
if there could be 'else' keyword to execute when try section ran without any errors and successfully(like python) it would be great
Is not the code right after the try-catch block a kind of else for the execution of the program?
1:30 lies, will I had a lot of issues with .then because it gives null and goes on
Either you are not returning, or your return is null
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?
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.
Watch out, Xamarin
who actually uses xamarin😂😂
Can flutter be used on rapidApi.com to make calls
Yeah, a sequence of multiple "then((){}" looks piled up
lol you the formatter then
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 :)
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 ?
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!
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.
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"
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?
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.
which country is on his t-shirt?
That is California, not a country. But I'd like to know what that "blank region" means.
What async* does?
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..
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
You should ask on stackoverflow
this has to be updated for the new isolate update 🤷🏾♂️
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?
as Android developer we need this kind of video explanation of how Kotlin flow works, if anyone has the video link, please share thanks
"... and the first time I saw them I remember being weirded out"
"Finally" block executes AFTER the return statement!!! Ouch. I think my old C-oriented mind may need to be reset... :-)
Forgot to explain how to handle the returned Future. That's the painful bit, IMHO
That was covered in a previous video - the easiest way is to pass it to a FutureBuilder.
Please use black background in future videos , watching this at night hurts .
Hi! Thank you very much for the feedback. We have shared your suggestion to our production team 😀
does anyone gets benefit from these videos?! I mean practicaly and using inside the code, I know that you would get an idea basically.
Using await is most simple 😂😂
i thing u can say 'just like javascript' and end the video ;P
please google make a framework that can use html&css&js to produce android and ios application
Ohio is a state
Heck yeah it is.
Flutter guides make Android courses like amateurs
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.
Very nice
Thanks Heshan!