关于flutter:Flutter-6-个建议改善你的代码结构

7次阅读

共计 569 个字符,预计需要花费 2 分钟才能阅读完成。

注释

1. 将 init 操作与 main 函数拆散,使其更加清晰

2. 你能够简略地治理这样的 GetX 路由,而不须要任何麻烦

  • 用法
Get.toNamed(Routes.login);
  • 怎么做

3. 你也能够在一个中央治理你的款式格调

  • 用法
// S stands for Styles

S.colors.red
S.textStyles.f10Medium
S.shadows.softShadow
  • 怎么做

4. 像 boss 一样治理你的资源

  • 用法
// R stands for Resources// Animations

R.anims.loading// SVG images
R.icons.logo// `mages
R.images.
  • 怎么做

5. 集中管理你的常量

  • 用法
// C stands for Constants

C.title
C.names
C.descp
  • 怎么做

6. 建设你的工具类 utils,咱们在一个中央应用所有的工夫

  • 用法
Utils.formatDate(date,locale);

Utils.formatters.onlyTwoDecimalDigits;

Utils.show.dialog();
  • 怎么做


© 猫哥

  • https://ducafecat.tech/
  • https://github.com/ducafecat
  • 微信群 ducafecat
  • b 站 https://space.bilibili.com/40…
正文完
 0