CustomPaint和FittedBox

时间:2019-02-25 23:47:27

标签: dart flutter flutter-layout

如何使CustomPaint适合父窗口小部件?

return new Container(
    color: Color(0xfffff4f0),
    child: new Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        mainAxisSize: MainAxisSize.max,
        children: <Widget>[
          new Expanded(
          flex: 6,
          child: FittedBox(
                  fit: BoxFit.contain,
                  child: widget CustomePaint() // Containers(),

          )),
          new Expanded(
              flex: 4,
          )
    )
)

fit:BoxFit.contain适用于

    Container(
        height: 30,
        width: 10
    )

但不适用于在画布矩形上绘制的CustomePaint():

canvas.drawRect(new Rect.fromLTWH(0, 0, 10 , 30), new Paint()..color = 
Colors.red);

enter image description here

0 个答案:

没有答案