V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
hxse
V2EX  ›  Flutter

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

  •  
  •   hxse · Apr 3, 2021 · 2011 views
    This topic created in 1860 days ago, the information mentioned may be changed or developed.

    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  
       Apr 7, 2021
    链式调用确实比较提倡,但对应层级太复杂的情况,做成链式调用会出现方法太多的问题,也很丑,
    Michelangelono
        2
    Michelangelono  
       Apr 9, 2021
    应该官方解决,第三方的不敢用。
    1219178163
        3
    1219178163  
       Jun 4, 2021
    先用再说,出问题的界面可以改为原生,毕竟效率第一。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1518 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 16:43 · PVG 00:43 · LAX 09:43 · JFK 12:43
    ♥ Do have faith in what you're doing.