Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

横竖屏切换布局错乱 #566

Closed
applebest opened this issue May 23, 2024 · 13 comments
Closed

横竖屏切换布局错乱 #566

applebest opened this issue May 23, 2024 · 13 comments

Comments

@applebest
Copy link

#414 (comment)

使用这种方式,改动源码可以解决横竖屏切换的问题 ,横竖屏切换后要重置设计比例

@applebest
Copy link
Author

image

@Mounir-Bouaiche
Copy link
Collaborator

@applebest Great idea, package used by many users including web and desktop that they are needing resize by width rather than orientation. You can use fontSizeResolver though (FontSizeResolver.[your_factor-radius in this case] or any other function), maybe conditionnaly based on device type

@applebest
Copy link
Author

@applebest Great idea, package used by many users including web and desktop that they are needing resize by width rather than orientation. You can use fontSizeResolver though (FontSizeResolver.[your_factor-radius in this case] or any other function), maybe conditionnaly based on device type

Is it possible to add a parameter to the initialization method to control via a variable whether or not the design ratio needs to be refreshed based on orientation?

@applebest
Copy link
Author

There is no screen rotation on the web and desktop, so there is no problem using width adaptation. On mobile phones and tablets, the screen rotation will be chaotic. Can the frame adapt? grateful

@Mounir-Bouaiche
Copy link
Collaborator

@applebest Great idea, package used by many users including web and desktop that they are needing resize by width rather than orientation. You can use fontSizeResolver though (FontSizeResolver.[your_factor-radius in this case] or any other function), maybe conditionnaly based on device type

Is it possible to add a parameter to the initialization method to control via a variable whether or not the design ratio needs to be refreshed based on orientation?

See Docs, fontSizeResolver parameter, in your case you can pass FontSizeResolvers.radius instead of default (FontSizeResolvers.width)

@applebest
Copy link
Author

@applebest Great idea, package used by many users including web and desktop that they are needing resize by width rather than orientation. You can use fontSizeResolver though (FontSizeResolver.[your_factor-radius in this case] or any other function), maybe conditionnaly based on device type

Is it possible to add a parameter to the initialization method to control via a variable whether or not the design ratio needs to be refreshed based on orientation?

See Docs, fontSizeResolver parameter, in your case you can pass FontSizeResolvers.radius instead of default (FontSizeResolvers.width)

FontSizeResolvers.radius only solves the font adaptation problem, the width and height of the widget are adapted using .w .h, when the screen is rotated . .w .h still uses the vertical scaling, I need to change the scaling according to the horizontal/vertical switch, because the width and height change when the screen is rotated.

@Mounir-Bouaiche
Copy link
Collaborator

@applebest This is expected, you should use your own code then with Flutter's LayoutBuilder widget, this package will not re-invent what is already built-in in flutter

@Mounir-Bouaiche
Copy link
Collaborator

Mounir-Bouaiche commented May 23, 2024

@applebest Great idea, package used by many users including web and desktop that they are needing resize by width rather than orientation. You can use fontSizeResolver though (FontSizeResolver.[your_factor-radius in this case] or any other function), maybe conditionnaly based on device type

Is it possible to add a parameter to the initialization method to control via a variable whether or not the design ratio needs to be refreshed based on orientation?

See Docs, fontSizeResolver parameter, in your case you can pass FontSizeResolvers.radius instead of default (FontSizeResolvers.width)

FontSizeResolvers.radius only solves the font adaptation problem, the width and height of the widget are adapted using .w .h, when the screen is rotated . .w .h still uses the vertical scaling, I need to change the scaling according to the horizontal/vertical switch, because the width and height change when the screen is rotated.

This is not a default for all developers, mobile developers also they want to calculate box width based on actual width of viewport whether landscape or portrait, so this custom feature will not be coded in this library. You should take a look at LayoutBuilder for this behaviour.

@Mounir-Bouaiche
Copy link
Collaborator

@applebest You can also use .r instead of .w and .h if you want the minimum value of width/height viewport, in any case

@applebest
Copy link
Author

@applebest您也可以使用.r而不是.w.h如果您想要宽度/高度视口的最小值,无论如何

Some public widgets use a lot of .w and .h when laying out. In landscape mode, I still want the public widgets to have good layout performance when rotating, so use .r This means that a lot of layout code needs to be modified based on rotation.

@Mounir-Bouaiche
Copy link
Collaborator

image

You can use this code, wrap ScreenUtilInit with LayoutBuilder and pass designSize according to orientation

@applebest
Copy link
Author

image

You can use this code, wrap ScreenUtilInit with LayoutBuilder and pass designSize according to orientation

Please send another picture, it was not uploaded, thank you

@Mounir-Bouaiche
Copy link
Collaborator

image

It's yours

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants