Original address: medium.com/flutter-com…

Gskinner_t…

Published: 14 April 2020-2 minutes to read

As we begin to push Flutter onto more platforms, such as the desktop and the web, it becomes increasingly important to quickly and easily measure the performance of your application. While the built-in performance monitor gets the job done, it leaves a lot to be desired in terms of readability.

To help alleviate this problem, we created StatsFl: pub.dev/packages/st…

To use it, simply wrap your root view in the StatsFl widget.

StatsFl(child: MyApp());
Copy the code

With this simple change, you’ll get a discrete FPS history chart at the top left of your app

In most cases, the default option should be what you need, but we’ve made it quite configurable just in case. The following figure shows StatsFl in three configurations. As you can see, the alignment, width and height can be adjusted. You can even turn showText off to get a minimalist mode (bottom).

In addition, you can adjust the length of sampleTime and totalTime to suit your needs. In this example, we calculate every 0.5 second for a total of 30 samples over a 15-second period.

return StatsFl( 
   sampleTime: . 5.//Interval between fps calculations, in seconds.
   totalTime: 15.//Total length of timeline, in seconds. 
   child: MyApp()
);
Copy the code

If you like this package, please throw a thumbs up to help increase popularity!


Posted on April 14, 2020 at blog.gskinner.com


www.deepl.com translation