简体   繁体   中英

Do you make classes for your custom Flutter widgets? Or keep them as constants in a dart file?

For example, if you have a bunch of custom buttons, do you make a class (for example, CustomButtons) and then have static functions that return different buttons? Or do you make dart files and make independent widget constants?

There are different ways to do custom widgets... like another one is having const widget themes and then creating widgets on the spot and using those themes.

What is the best practice?

It depends If you have a complex widget then you must create a separate file and create your custom widget there. But if your widget is small then use static function etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM