27_Flutter之SizedBox组件

Flutter之SizedBox组件

一.参数说明

const SizedBox({ 
    Key key, 
    this.width, 
    this.height, 
    Widget child 
  })
  
const SizedBox.expand({ Key key, Widget child })
    : width = double.infinity,
      height = double.infinity,
      super(key: key, child: child);
      
const SizedBox.shrink({ Key key, Widget child })
    : width = 0.0,
      height = 0.0,
      super(key: key, child: child);
      
SizedBox.fromSize({ Key key, Widget child, Size size })
    : width = size?.width,
      height = size?.height,
      super(key: key, child: child);

1.如果width和height不为null,SizedBox会强制其子组件拥有特定的宽高,否则,SizedBox会调整自身的大小来适应子组件的大小

27_Flutter之SizedBox组件_第1张图片

27_Flutter之SizedBox组件_第2张图片

你可能感兴趣的:(Flutter)