As the title indicates, in my opinion the extensions .h, .w, .sp, do not work correctly, maybe there is some concrete reason why you have done it and that is beyond my knowledge, but for the moment I think it should work otherwise and I'll explain why below.
1- .w and .h extensions
I was reviewing the package and I saw that when setScreenSize() changes the value of adaptiveWidth and adaptiveHeight, you put an if loop to verify that if the orientation is in portrait mode and set its value in this way, that is;
if (orientation == Orientation.portrait) {
adaptiveWidth = boxConstraints.maxWidth;
adaptiveHeight = boxConstraints.maxHeight;
} else {
adaptiveWidth = boxConstraints.maxHeight;
adaptiveHeight = boxConstraints.maxWidth;
}
Nothing you do not know until there, but as I said before in my humble opinion, I think it should work in another way, that is, it should not be this cycle, because when I want to change a size in landscape mode I want my adaptideWidth is the actual width that I currently have when being in landscape mode and not the width that it would have in portrait mode, perhaps for the size of the letter if it works because it is the same size in the two orientations but for the sizes of a Container() for example, in my opinion not. I repeat that maybe I'm wrong but I think it should always be the width of the screen whether you are in landscape or portrait mode, that is.
adaptiveWidth = boxConstraints.maxWidth;
adaptiveHeight = boxConstraints.maxHeight;
2- .sp extension
Something similar to the previous ones happens to this extension, that is, when you do the operation;
double get sp => this * (Device.adaptiveWidth / 3) / 100;
You only take into account the width of the screen, but for me this is an error, I put an example so that you understand:
Now I have a device with a size of, 1366x768 in landscape mode and 768x1366 in portrait mode (I use computer sizes because they are the ones I know the most), then I create a Container() with a size of 20% of the height and 20% of the width in portrait mode, and inside I add a Text() with a size that fits the size of the Container() but does not come out outside of it.
And now I launch my application on a device with a screen that has a size of 1280x768 in landscape mode and 768x1280 in portrait mode.
If I take as a reference the width of the screen in portrait mode to adjust the size with the extension ".sp", since the width is now 768 the same as before, and the height is 1280 less than before, my Text() It will be seen with a size the same as before, which will cause the letter to be cut off because it no longer fits the dimensions of the Container() that I had created, since the height is reduced but the font size It remains the same.
To fix this problem I have created my own test function, which would be like this:
double textSize(BuildContext context, num mySize) {
final h = MediaQuery.of(context).size.height;
final w = MediaQuery.of(context).size.width;
double result = mySize * (((h + w) / 2) / 4) / 100;
return result;
}
and if you wanted to add it to your package it would be like this:
double get sp => this * (((Device.adaptiveWidth + Device.adaptiveHeight) / 2) / 4) / 100;
In this way, if you change any of the two sizes of the screen, the text adapts accordingly because it takes into reference the total resolution of the screen and not only the width.
Even to be totally exact, the pixelRatio and the aspectRatio could also be taken into account, being this way:
double get sp => this * (((Device.adaptiveWidth + Device.adaptiveHeight + MediaQuery.of (context) .devicePixelRatio + MediaQuery.of (context) .size.aspectRatio) / 2) / 4) / 100;
which would not change the final value too much, but it would make it even more precise since not all phones are the same even if their resolutions are the same.
PS: If you divide "/ 4.5"
double get sp => this * (((Device.adaptiveWidth + Device.adaptiveHeight) / 2) / 4.5) / 100;
It will give you a result more similar to the result that it gave with
double get sp => this * (Device.adaptiveWidth / 3) / 100;
in this way it will be easier to adapt to your design if someone was using the package, since the sizes will be more or less the same but it will adapt depending on the total resolution of the screen.
What happens that I have divided by 4 because I love whole numbers XD
If I make a mistake with something, sorry, do not hesitate to correct me, but I only try to help because I like this package since I know of the headaches that adapting the application to all screens gives and I think this is the best way to do it.
Regards, and thanks for your work.