不能在row或者column里面直接使用stack,需要在stack外面包裹一个大小确定的Container
错误写法为:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('身份证照片(选填)',style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1),fontSize: 14.sp),),
SizedBox(height: 6.h,),
Stack(
children: [
Positioned(child: Image.asset('images/img1@3x.png'),left: 0,width: 160.w,top: 0,height: 100.h,),
Positioned(child: IconButton(icon: Image.asset('images/paishe@3x.png'),onPressed: (){},),left: 58.w,top: 28.h,width: 44.w,height: 44.w,),
Positioned(child: Image.asset('images/img2@3x.png'),right: 0,width: 160.w,top: 0,height: 100.h,),
Positioned(child: IconButton(icon: Image.asset('images/paishe@3x.png'),onPressed: (){},),right: 58.w,top: 28.h,width: 44.w,height: 44.w,)
],
)
],
)
正确写法:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('身份证照片(选填)',style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1),fontSize: 14.sp),),
SizedBox(height: 6.h,),
Container(
width: 335.w,
height: 120.h,
child: Stack(
children: [
Positioned(child: Image.asset('images/img1@3x.png'),left: 0,width: 160.w,top: 0,height: 100.h,),
Positioned(child: IconButton(icon: Image.asset('images/paishe@3x.png'),onPressed: (){},),left: 58.w,top: 28.h,width: 44.w,height: 44.w,),
Positioned(child: Image.asset('images/img2@3x.png'),right: 0,width: 160.w,top: 0,height: 100.h,),
Positioned(child: IconButton(icon: Image.asset('images/paishe@3x.png'),onPressed: (){},),right: 58.w,top: 28.h,width: 44.w,height: 44.w,)
],
),
)
],
)