Flutter: Introducing StatsFl, an FPS monitor for Flutter

As we begin pushing Flutter to more platforms such as Desktop and Web, it is becoming increasingly important to quickly and easily measure 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 and flexibility.

As the old school Flash devs we are, we remember the days when virtually every Flash application around would use the hi-res-stats package by mrdoob (yes, that mrdoob). It was extremely helpful to catch performance issues, and make sure your application was smooth (which in those days, was a solid 24fps!).

Currently nothing like that exists in the Flutter community. To help fill this gap, we’ve created StatsFl! Available now on pub.dev: https://pub.dev/packages/statsfl

To use, just wrap your root view (or really, any view) in the StatsFl widget:

StatsFl(child: MyApp());

With that simple change you’ll get a discrete FPS history chart in the top-left of your application! By default it will show your last 15 seconds of activity, with two samples each second.

For the most part the default options should be all you need but just in case, we’ve made it fairly configurable. The image below shows StatsFl in 3 configurations.

This image has an empty alt attribute; its file name is chrome_2020-04-12_22-11-09.png

As you can see, alignment, width and height are all adjustable. You can even toggle off showText for a minimalist mode (bottom).

Additionally, you can adjust the sampleTime and totalTime to be as long as you need. In this example, we’re calculating every .5 seconds, over a 15 second period, for a total of 30 samples.

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

If you like the package, please toss a thumbs up on pub.dev to help increase the popularity!

shawn.blais

Shawn has worked as programmer and product designer for over 20 years, shipping several games on Steam and Playstation and dozens of apps on mobile. He has extensive programming experience with Dart, C#, ActionScript, SQL, PHP and Javascript and a deep proficiency with motion graphics and UX design. Shawn is currently the Technical Director for gskinner.

@tree_fortress

One Comment

  1. If at gskinner you are enthusiastic about Flutter, as a 20 years long Flash/AIR developer, I will consider stepping into flutter too. Love from Italy.

Leave a Reply

Your email address will not be published. Required fields are marked *