ReinBentdal / styled_widget

Simplifying widget style in Flutter.
https://pub.dev/packages/styled_widget
MIT License
1.27k stars 103 forks source link

Effect on Performance #71

Open gfyre opened 2 years ago

gfyre commented 2 years ago

Hey guys! I just discovered Styled_Widgets and I'd like to say Kudos! for building such a wonderful library.

I have 2, rather simple questions.

  1. Would using this package have any effect on the performance of the app, assuming that it is a graphically intensive application?
  2. Can I use this to build a desktop app? (I am assuming that I can because of how flutter compiles Dart code to desktop bundles)

Thanks!

ReinBentdal commented 2 years ago

Hello! I have not done any specific tests to check how the package effects performance. However in my personal experience building apps, the performance has always been good. Since the library only generates widget trees there shouldn't be a big hit on performance. However someone has to measure this to verify.

It should work perfectly fine on desktop as well. There might be some missing widgets which is not implemented. It is easy to extend this library. Just make a pull request for new widgets and I will probably accept!

alguintu commented 2 years ago

Does this package lose the benefits of the const tables for widgets? E.g.:

Padding(
   padding: const EdgeInsets.all(8)
);

According to flutter/dart docs, all const widgets are built into a table on compile time, and then looked up on rendering to ensure they never get rebuilt needlessly.

Just wonder how this library affects rebuild count and framerates on fairly complex widget trees.

daniloapr commented 2 years ago

I have this same concern. As far as I know, it's based on extensions, which is similar to having helper functions returning Widgets and this is not recommended by the Flutter team (video on Youtube). Is that right?

For smaller apps it won't be a problem. My concern is how does it scale.

ReinBentdal commented 2 years ago

I don't think the issue they discussed in the video is exactly applicable. It's about unnecessary rebuilds of features, which is solved by isolating features in widgets. Flutter will then only rebuild widgets where the parameters has changed. But the widgets may use styled_widget. That being said, again, it has to be measured and tested to see the actual impact of styled_widget