skip to Main Content

I have a question about using flutter_screenutil package.
the package has two methods for setting widths and heights,
first one when using ScreenUtil().setWidth(540) or ScreenUtil().setHeight(540)
and the second one when using extensions like 540.w or 540.h
I am confused about which method should i use.
so can you help me please?

2

Answers


  1. If your dart sdk>=2.6, you can use extension functions:

    example:

    instead of :

    Container(
      width: ScreenUtil().setWidth(50),
      height:ScreenUtil().setHeight(200),
    )
    

    you can use it like this:

    Container(
      width: 50.w,
      height:200.h
    )
    
    Login or Signup to reply.
  2. you can use any one method , both methods will give you same result

    Container(
      width: ScreenUtil().setWidth(540),
      height:ScreenUtil().setHeight(540),
    )
    
    Container(
      width: 540.w,
      height:540.h,
    )
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search