flutter-超出部分隐藏

第一种写法

 1 ConstrainedBox(
 2   constraints: BoxConstraints(
 3     maxHeight: 100
 4   ),
 5   child: Stack(
 6     overflow: Overflow.clip,
 7     children: <Widget>[
 8       Container(
 9         width: 100,
10         height: 200,
11         color: Colors.greenAccent,
12       )
13     ],
14   ),
15 ),

第二种写法

Container(
  color: KColor.redBg,
  constraints: BoxConstraints(maxWidth: 500.w),
  child: Stack(
    overflow: Overflow.clip,
    children: [
      Container(
        width: 600.w,
        color: KColor.blackTextColor,
       ),
       ],
    ),
),

 

posted @ 2020-11-30 11:26  mingV2020  阅读(5304)  评论(0编辑  收藏  举报