Dart Isolates - Flutter compute function - Multithreading in Dart and Flutter

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ก.ย. 2024

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

  • @user-oj2tq1lp6o
    @user-oj2tq1lp6o 3 ปีที่แล้ว +2

    Quick, understandable and helpful. You and people like you are gifts from the god himself for the humanity. Thanks for the great video!

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

      Thank you for this amazing feedback! I am glad that it helped you :)

  • @khanisrarahmedalihusain
    @khanisrarahmedalihusain 3 ปีที่แล้ว +4

    I haven't used it yet, but I found there are some cases in my Project where I can use it and I will.

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

    One of the more clear explanations, well done!
    I haven't used them, yet, I'm kind of looking into them because I think I might need them.
    My use case:
    I'm creating a Solver for my own puzzle game. It will look for all the possible solutions. For the smaller puzzles, this works in a matter of milliseconds, but when it tries to solve a complex puzzle, it might take seconds, or even minutes.
    I feel like that's a good use-case because I can run the solver without blocking the app (as it's currently doing).

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

      Sounds really like a perfect usecase, but in general I am not really happy with that video :) it was a bit to complex and talked into multiple layers, I have it on my list to create an Isolates Version 2 video :)

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

      @@FlutterExplained Here's a question, say that the code is running on a four core processor. Is there a way I can assign specific code to run on a specific core only??? I.e. I want to give specific code its own core for various security/performance reasons. I imagine there's probably a way to do this by pulling out the compiler source code lol.

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

    Thank You! Very interesting and helpful video! From Russia with love!

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

    Thanks a billion. This is the best explanation of isolates and compute so far.

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

    Understood how to work with isolates but had to go through it multiple times though worth the time.
    Thanx for the amazing video💙

  • @user-od6kj6hd2n
    @user-od6kj6hd2n 3 ปีที่แล้ว +2

    Thank man you are the only one make me understand Isolate❤️

  • @dilshan3372
    @dilshan3372 4 ปีที่แล้ว +2

    You have done great job for flutter .
    Thanks for your explanations😇☺️

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

      Thank you so much, I am so happy that it helped you :)

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

    helpful on an offline-first approach, consuming a queue of offline events that need to be synchronized with the cloud without blocking the UI. Doing that without Isolates led me to frame drops.

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

    Thank you for sharing your knowledge!

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

      You are most welcome, I hope you can use it :)

  • @medamine194
    @medamine194 3 ปีที่แล้ว +4

    very great explanation.
    i think you could use your white board to explain complex topic like this with drawing... its very useful.

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

      Thank you for your feedback and the idea, I will try to think about it the next time :).

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

    my stopwatch app is stop running when a press the back button, i ear the isoltate can be the solution. how can i implement it please?

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

    9:10 I have a confusion on line no.22 => inside compute function we've called computeFunction but didn't pass the params in it. Intead we've used (,) then passed params (random...).

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

      On line 22 we have not called the computeFunction. We passed it (by name, without parentheses) as an argument to the compute function.
      The compute function will invoke any passed function with provided arguments inside a newly spawned isolated thread for us.

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

    Hi sir i like way you explain the topic and i new in flutter and thanks to help..... 🙏

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

      You are most welcome :) thank you for the feedback. ☺️

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

    i am making an application wherein we are using webrtc.....could you help me by telling how we can play the video(in pip mode) in while the app is in background.

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

    My application requires reading a lot of images from memory and displaying then in a list.these images are often huge in size so takes a lot of time loading them. Is isolate best for this scenario?

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

      I saw some flutter packages uses isolates for this exact purpose - reading images (e.g. from cache).
      So looks like a nice use case.

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

    Can two isolates interact with a single db on device, something like sqflite?

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

      Should be possible, but be mindful with transactions and async because it could created it faster / slower then the other process.

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

      no. You cannot use isolates with platform channel apis like sqflite. It will work for objectbox or hive

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

    Can I get a progress from a compute function?

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

    I have an api that takes 8-10 seconds to get response. By the time I want to navigate through app when my function is still running. Which best method can I use? Thanks!

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

    I have been able to make use use of it in a project I needed to do some background upload.

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

    I created a button to run a loop to print any sentence and I quit the application after pressing the button and the application is in the background I did not close it completely and the Loop is still working This means that when a code is in an active state or a specific event, it is still happening in the background Am I right or No

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

    thanks for great tutorial

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

    Great thanks for the topic

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

      You are very welcome :). I hope it fits your needs!

  • @mikemannox4191
    @mikemannox4191 4 ปีที่แล้ว

    With regards to compute - How can I pass it a reference of a method and its args for isolate processing? Thx

  • @sammason547
    @sammason547 4 ปีที่แล้ว +2

    Hi, this video was great and really helped me! I am just having issue with trying to kill the isolate to prevent the completion of a task on a button press? Any help is much appreciated it!

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

      If you use an isolate class you could work with the kill method and intercept the computation. api.flutter.dev/flutter/dart-isolate/Isolate/kill.html

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

      @@FlutterExplained Thanks for the response, I looked into it a bit more and managed to figure a solution! Thanks!

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

      Amazing congratulations :)

  • @user-tq6zu3sl1y
    @user-tq6zu3sl1y ปีที่แล้ว

    Hi,
    below error showing, share sample code API Calling
    The BackgroundIsolateBinaryMessenger.instance value is invalid until BackgroundIsolateBinaryMessenger.ensureInitialized is executed.

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

    I think this won't be relevant for me as I just know how to make UIs in flutter. But I'm confused which libraries are useful to me and how do I find libraries relevant to myself. I don't have a project as such but wanna know more about flutter. Any suggestions about how to go ahead?

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

      I think to evaluate if a particular package is useful for you, you will have to test it out. If you want to know in general more about Flutter I can recommend you the Flutter roadmap in this article:
      medium.com/flutterdevs/roadmap-to-become-a-flutter-developer-resources-for-beginners-ccb68718c84b

    • @pranishramteke7642
      @pranishramteke7642 4 ปีที่แล้ว

      @@FlutterExplained Thanks a lot. This seems helpful, I'll check and follow this. Hopefully I'll catch up. Thanks man.

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

      You are very welcome, if you have more questions feel free to ask on twitter anytime :)

    • @pranishramteke7642
      @pranishramteke7642 4 ปีที่แล้ว

      @@FlutterExplained sure. I will. Now, a flutter expert has my back :')

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

    I had to read 500+ page PDF. Its super slow process so i think isolate is the solution

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

    10:52 with this question I came here, but didn't got any answer, even one was promised at 0:13

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

    so is this really the simplest way to describe how multithreading works in dart? Cause it's quite complicated for my particular brain.. calling APIs and whatnot.. can't you just make an example where you do some adding or something? All examples of isolates on youtube are complicated... or maybe I'm just too dumb

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

    k, I used to hav reasonalble knowledge f ports u just confused me on this 1 lol....(some kinda diagram might helped with ports, dart team themselves did poor job naming ports very confusing for me)

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

      Uh sorry to hear that, maybe I can help to reduce the confusion? Which part was not clear?

    • @pradeep422
      @pradeep422 4 ปีที่แล้ว

      will try to watch more slowly!!!

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

      should hav used tht white board in background lol

    • @pradeep422
      @pradeep422 4 ปีที่แล้ว

      sry for dislike

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

      @@pradeep422 Yeah, here on that video I have also a graph that could maybe help you.
      th-cam.com/video/AORz7-0OY9k/w-d-xo.html

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

    there are too many working around if you are a "software eng" you should really observe that!.
    and why are you using ports like that?
    just use one receive port and one send port in each of the isolate!

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

      Hi there, thanks for your feedback and sorry that you did not like the video. I will try to improve in the future.

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

      @@FlutterExplained
      Looking forward for new videos.
      All the best 😊

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

      @@nidalbakir4720 Thank you :)

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

      @@FlutterExplained this seems like a generic bot answer... lifeless..

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

    Why didn't Flutter make it simple as coroutines 😏😭