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

前端 未结 8 481
终归单人心
终归单人心 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:49

    Referring to https://dart.dev/guides/language/effective-dart/design

    It's a good practice to group, constants and enum-like types in a class like below:

    One small advantage this has over the most voted answer, is in Android Studio, your can type the class name Color in your code, and Android Studio will be able to suggest auto import of Color class. This is not possible with the most voted answer.

提交回复
热议问题