flutter超出部分隐藏

第一种写法

 1 ConstrainedBox(
 2   constraints: BoxConstraints(
 3     maxHeight: 100
 4   ),
 5   child: Stack(
 6     overflow: Overflow.clip,
 7     children: <Widget>[
 8       Container(
 9          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(
         600.w,
        color: KColor.blackTextColor,
       ),
       ],
    ),
),
原文地址:https://www.cnblogs.com/mingv/p/14060317.html