美文网首页
Flutter 6 个建议改善你的代码结构

Flutter 6 个建议改善你的代码结构

作者: 独立开发者猫哥 | 来源:发表于2021-11-08 09:17 被阅读0次
    image

    正文

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

    image

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

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

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

    • 用法
    // S stands for Styles
    
    S.colors.red
    S.textStyles.f10Medium
    S.shadows.softShadow
    
    • 怎么做
    image

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

    • 用法
    // R stands for Resources// Animations
    
    R.anims.loading// SVG images
    R.icons.logo// `mages
    R.images.
    
    • 怎么做
    image

    5. 集中管理你的常量

    • 用法
    // C stands for Constants
    
    C.title
    C.names
    C.descp
    
    • 怎么做
    image

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

    • 用法
    Utils.formatDate(date,locale);
    
    Utils.formatters.onlyTwoDecimalDigits;
    
    Utils.show.dialog();
    
    • 怎么做
    image

    © 猫哥

    相关文章

      网友评论

          本文标题:Flutter 6 个建议改善你的代码结构

          本文链接:https://www.haomeiwen.com/subject/ynhuzltx.html