MAHMOUD
MAHMOUD

Reputation: 1

confused about using flutter_screenutil package

I have a question about using flutter_screenutil package.

The package has two methods for setting width and height.

  1. First one when using ScreenUtil().setWidth(540) or ScreenUtil().setHeight(540)
  2. when using extensions like 540.w or 540.h

I am confused about which method should I use?

Upvotes: 0

Views: 367

Answers (2)

yash oza
yash oza

Reputation: 51

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,
)

Upvotes: 0

Vu Thanh
Vu Thanh

Reputation: 398

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
)

Upvotes: 1

Related Questions