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

how to set Orientations for a certain page? #277

Open
zhaoyul opened this issue Oct 10, 2023 · 3 comments
Open

how to set Orientations for a certain page? #277

zhaoyul opened this issue Oct 10, 2023 · 3 comments

Comments

@zhaoyul
Copy link

zhaoyul commented Oct 10, 2023

No description provided.

@dupuchba
Copy link
Contributor

hello @zhaoyul , can you be more specific in your question?

@zhaoyul
Copy link
Author

zhaoyul commented Oct 10, 2023

Thanks for the timely reply^_^ @dupuchba

I want the following page to be in landscape mode. and when it goes back, flip back to original (portrait) mode.

(def static-route
  (m/Scaffold
   .appBar (m/AppBar .title (m/Text "static monitor"))
   .body
   (f/widget
    :get [m/Navigator]
    :watch [ _ (s/SystemChrome.setPreferredOrientations [s/DeviceOrientation.landscapeLeft]) ;; <=== I don't think it's a good idea
            ]
    m/Center
    (m/ElevatedButton .onPressed #(.pop navigator))
    (m/Text "Go back!"))))

SystemChrome.setPreferredOrientations returns a promise, is there a way to write something like

void main() {
  SystemChrome.setPreferredOrientations(
    [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]
  ).then((_) {
    runApp(MyApp());
  });
}

Should I use await

@dupuchba
Copy link
Contributor

https://api.flutter.dev/flutter/services/SystemChrome/setPreferredOrientations.html
according to documentation it only works on iPad.
These kind of features are OS dependent and are not forced by flutter.
What are the OSes you target?

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