原文

https://itnext.io/5-flutter-tips-for-better-code-structure-fa514845a903

正文

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

2. 你可以简单地管理这样的 GetX 路由,而不需要任何麻烦

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

3. 你也可以在一个地方管理你的样式风格

  • 用法
1
2
3
4
5
// S stands for Styles

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

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

  • 用法
1
2
3
4
5
// R stands for Resources// Animations

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

5. 集中管理你的常量

  • 用法
1
2
3
4
5
// C stands for Constants

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

6. 建立你的工具类 utils,我们在一个地方使用所有的时间

  • 用法
1
2
3
4
5
Utils.formatDate(date,locale);

Utils.formatters.onlyTwoDecimalDigits;

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

© 猫哥

往期

开源

GetX Quick Start

https://github.com/ducafecat/getx_quick_start

新闻客户端

https://github.com/ducafecat/flutter_learn_news

strapi 手册译文

https://getstrapi.cn

微信讨论群 ducafecat

系列集合

译文

https://ducafecat.tech/categories/%E8%AF%91%E6%96%87/

开源项目

https://ducafecat.tech/categories/%E5%BC%80%E6%BA%90/

Dart 编程语言基础

https://space.bilibili.com/404904528/channel/detail?cid=111585

Flutter 零基础入门

https://space.bilibili.com/404904528/channel/detail?cid=123470

Flutter 实战从零开始 新闻客户端

https://space.bilibili.com/404904528/channel/detail?cid=106755

Flutter 组件开发

https://space.bilibili.com/404904528/channel/detail?cid=144262

Flutter Bloc

https://space.bilibili.com/404904528/channel/detail?cid=177519

Flutter Getx4

https://space.bilibili.com/404904528/channel/detail?cid=177514

Docker Yapi

https://space.bilibili.com/404904528/channel/detail?cid=130578