OpenFlutter / flutter_screenutil

Flutter screen adaptation, font adaptation, get screen information
https://pub.dartlang.org/packages/flutter_screenutil
Apache License 2.0
3.88k stars 494 forks source link

使用w固定控件高度后,在不同尺寸的手机上显示效果不同 #445

Closed moujunqiang closed 1 year ago

moujunqiang commented 1 year ago

使用的size大小是 375*812 在小屏幕的手机上显示超出范围,大屏幕手机上可以正常显示 231671161789_ pic 221671161788_ pic 下面是代码 Container( margin: EdgeInsets.only(top: 20.w), alignment: Alignment.centerLeft, height: 125.w, child: Row( children: [ Image.network( "https://img0.baidu.com/it/u=2862534777,914942650&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500", width: 100.w, height: 125.w, fit: BoxFit.fill, ), Expanded(

                child: Container(
                  color: Colors.red,
                  margin: EdgeInsets.only(left: 15.w),
                  height: 125.w,
                  alignment: Alignment.topLeft,
                  child: Column(

                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      SizedBox(height: 3.w,),
                      Text("医学存在的终极理由课程",style: TextStyle(fontSize: 17.sp,color: Colors.black,fontWeight: FontWeight.bold),),
                      SizedBox(height: 5.w,),
                      Row(
                        children: [
                          Text("共12课时 |",style: TextStyle(fontSize: 12.sp,color: HexColor("#9f9f9f")),),
                          Text("12.4小时 |",style: TextStyle(fontSize: 12.sp,color: HexColor("#9f9f9f")),),
                          Text("分",style: TextStyle(fontSize: 12.sp,color: HexColor("#9f9f9f")),),
                        ],
                      ),
                      SizedBox(height: 10.w,),
                      Text("推荐理由",style: TextStyle(fontSize: 12.sp,color: HexColor("#61c0bf")),),
                      SizedBox(height: 10.w,),
                      Container(
                        padding: EdgeInsets.all(5.h),
                        decoration: BoxDecoration(
                          border: Border.all(color: HexColor("#e8f2f1"),width: 1.w),
                          borderRadius: BorderRadius.circular(5.w),
                        ),
                        child: Text(
                            "推荐于:由推荐理由推荐理由推荐理由,推荐理由推荐理由推荐理由",
                        style: TextStyle(fontSize: 12.sp),),
                      ),
                    ],
                  ),
                ))
          ],
        ),
      ),
wumeixinjiazu commented 1 year ago

SizedBox(height: 10.w,), 不应该是SizedBox(height: 10.h,),

moujunqiang commented 1 year ago

SizedBox(height: 10.w,), 不应该是SizedBox(height: 10.h,),

我写的是SizedBox(height: 10.w,), 超出了范围

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

lizhuoyuan commented 1 year ago

父组件建议高度不要限制死, 因为不同手机会变成不同的尺寸,无论是用h还是w都无法保证不溢出. 或者看看是不是高度上的适配不一致