Reputation: 2832
I'm using MethodChannel.invoke
to call some platform code to return app icons as Uint8List
s. This happens for a list of all the apps on a device (can be quite a lot), displayed as FutureBuilder
s in a ListView.builder
.
This caused a lot of stutter when scrolling quickly in the ListView
, so I changed it so that all the app icons are preloaded before displaying the ListView. This fixes the scrolling, but the UI is very janky while the icons are loading.
I believe the problem may be the same as this issue, and I shouldn't be loading the icons on the UI thread the way it is now. However, looking at the docs for compute
, I don't think I will be able to use it to call platform code.
Is there another way I can avoid the UI lag?
Upvotes: 3
Views: 1194
Reputation: 2832
pskink's suggestion of using a HandlerThread
did the trick! I now can scroll smoothly even without preloading.
Upvotes: 2