What's the best practice to keep all the constants in Flutter?

前端 未结 8 486
终归单人心
终归单人心 2021-01-30 02:11

What\'s the best programming practice to

create a constant class in Flutter

to keep all the application constants for easy referenc

8条回答
  •  庸人自扰
    2021-01-30 02:35

    Dart documentation says explicitly "AVOID defining a class that contains only static members." dart.dev/guides/language/effective-dart/design

    The approach I use is creating one or more files to store those constants. Sometimes, when your project is too big it might have a lot of them, and in order to load less data, I prefer to separate them by the different contexts I would use them creating separate files. So I only import the ones that I would use.

提交回复
热议问题