I am currently working on a vnc lib in dart and my question is how to draw the array of pixels i am getting from the server efficiently in dart/flutter. Currently the buffer of pixels and the Image ist being reused so that there is no allocation overhead.
Since i already started implementing a vnc client in Kotlin GitHub i want to share the way i did it there because it was also for the mobile platform.
I implemented it in the way that there is very few memory allocation overhead in the code because the lib had a lot of strugle with the garbage collector time. So i declared all the variables only one time and reused them. The same way how i used the Bitmap showing the current state of the Desktop only once. I just updated the pixels according to the new state of the desktop. In Kotlin / Classic Android development you want to use Bitmap.setPixels() since that is pretty lowlevel and efficient as i know.
So what is the best way to realize that in Dart / Flutter without having the overhead of creating an object every time the function is called.