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

Listen flutter screenutil for changes #455

Closed MohammedHelewa closed 1 year ago

MohammedHelewa commented 1 year ago

When giving the values directly, as in the first example (Ex.1), things are going correctly and there are no problems. But I built a class, put the values in it, and then called them as in the second example (Ex.2) to make the modification easier and more readable. A problem appears with me, which is:

The values are only modified when the application is restarted (I do not mean Hot Reload)

Direct use of it is like this. (Ex.1)

Container(
  width: 250.w,
  height: 330.h,
),

(Ex.2)

class AppSizes {

  static double containerWidth = 250.w;
  static double containerheight = 330.h;

  //...
}
Container(
  width: AppSizes.containerWidth,
  height: AppSizes.containerheight,
),

What happens to me:

When you run the application for the first time in portrait mode, things work correctly, but when you make the application in landscape mode, the distances remain as they were in portrait mode, so I need to restart the application in landscape mode so that the distances are correct, and vice versa.

How do I make class directly record changes directly?