Note: Certain expensive widgets like Opacity, Chip, ShaderMask, ColorFilter and Text with overflowShader need to be used with careful consideration as they might triggersaveLayer()` behind the scenes. Here's a pictorial representation of the results:.Import 'package:ui_profiling/utils/utils.dart' Ĭlass LongListView extends StatefulWidget",īorderRadius: BorderRadius.circular( 200)), Next, use the following code to implement the ListView for your application:.(Refer to the previous article to know why it has to be rendered in 16ms). It can be observed that building such a simple list was heavier on the UI thread and Raster thread with some frames taking more than the sixteen milliseconds recommended to be rendered.In the given example, a simple list view having ten thousand items have been rendered with each item having a user image and user name along with an additional slide-in transition for each item.To do this, click on the "Clear" button present at the top left and enable the performance overlay to overlook the UI and raster threads like discussed in the previous article. The UI profiling can be started afresh by clearing the timeline after the first build.Now, you should be able to see the Flutter DevTools as shown in the picture:.Next, click on the generated link to access the Flutter DevTools as shown below:.Run your app in Profile mode using the following code:.Additional checks like assertions are added to aid development when using the debug mode and the code is compiled JIT(just in time) whereas in profile or release mode, code is precompiled to transmit native instructions i.e AOT(ahead of time) which makes it more preferable for this process. Simulators or emulators have differences in hardware when compared to real devices. For the best results, choose the slowest device possible and use the same device throughout for measuring the performance.Do not measure in an iOS simulator or Android emulator as Flutter doesn't allow you to run the required Profile mode on a simulated device. ![]() Only measure the performance on a real device.Do not measure performance when in "Debug" mode. Only measure the performance of an app when in "Profile" mode.Towards the end, we will be able to measure how the app's performance has improved after refactoring the code. In this article, we will be profiling an app that is used to render huge lists having transitions by making use of UI performance tools to identify issues and refactor the code. Displaying long lists, handling complex animations or transitions has always been a daunting task for every Flutter developer due to the jank received during this process. As we proceed with this article, let's take this learning further and start with the UI profiling of an inefficient Flutter app. In the previous article, we got an overview of the UI performance tools that can be used on Flutter.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |