V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hxse
V2EX  ›  Flutter

发现了一个解决 Flutter 嵌套过深的包

  •  
  •   hxse · 2021-04-03 15:51:43 +08:00 · 1356 次点击
    这是一个创建于 1090 天前的主题,其中的信息可能已经有所发展或是发生改变。

    https://pub.dev/packages/styled_widget

    native flutter

    Align(
      alignment: Alignment.center,
      child: DecoratedBox(
        decoration: BoxDecoration(
          color: Colors.amber,
        ),
        child: Padding(
          padding: EdgeInsets.all(10),
          child: Text('some text'),
        ),
      ),
    );
    

    styled_widget

    Text('some text')
      .padding(all: 10)
      .backgroundColor(Colors.amber)
      .alignment(Alignment.center);
    

    看起来清爽多了, 大家觉得怎么样?

    AoEiuV020
        1
    AoEiuV020  
       2021-04-07 11:12:22 +08:00
    链式调用确实比较提倡,但对应层级太复杂的情况,做成链式调用会出现方法太多的问题,也很丑,
    Michelangelono
        2
    Michelangelono  
       2021-04-09 10:29:55 +08:00
    应该官方解决,第三方的不敢用。
    1219178163
        3
    1219178163  
       2021-06-04 16:15:15 +08:00
    先用再说,出问题的界面可以改为原生,毕竟效率第一。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3160 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 12:24 · PVG 20:24 · LAX 05:24 · JFK 08:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.