[Flutter] landscape, portrait #fullscreen #system

2024. 2. 11. 18:07dev/flutter

728x90
반응형
MediaQuery.of(context).orientation == Orientation.portrait ?

 

        // 하단 네비게이션 바를 숨김
        bottomNavigationBar: null,
        // 키보드가 나타날 때 화면이 조정되지 않도록 함
        resizeToAvoidBottomInset: false,
      ),
      // 앱의 상태 표시줄을 숨김
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        // 상태 표시줄의 색상을 투명으로 설정
        appBarTheme: AppBarTheme(
          color: Colors.transparent,
          brightness: Brightness.dark, // 상태 표시줄 글자 색상을 밝게 설정
        ),
        // 전체 화면에 앱을 배치
        scaffoldBackgroundColor: Colors.black,
      ),

 

하단 네비게이션만 없애기

(과거)

SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top]);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.top]);

 

상단 상태바만 없애기

(현재)

SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]);
  // 하단만 보이게 함,
  // 하지만 상단을 드래그하면 이후로 상단도 노출되게 함
  SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom]);

 

풀스크린(전체 꽉~찬 화면)

// 상태바, 하단바 모두 없앤 FullScreen상태 유지
// 드래그해서 시계나 하단 네비게이션을 부른 경우 Sticky상태는 없애준다.
// overlays를 준 경우 효과가 없네..?
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);

 

2024-04-15-월

immersive : 화면이 꽉차고 회전 불가

immersive : 화면이 꽉차고 회전 가능

 

 

화면회전 자동, 가로 고정, 세로 고정

가로 고정

SystemChrome.setPreferredOrientations(
  [
    DeviceOrientation.landscapeLeft,
    DeviceOrientation.landscapeRight,
  ]
)

 

 

세로 고정

SystemChrome.setPreferredOrientations(
  [
    DeviceOrientation.portraitUp,
    DeviceOrientation.portraitDown,
  ]
)
if (beforeOrientation != textScreenOrientation) {
  switch (textScreenOrientation) {
    case "가로 고정":
      SystemChrome.setPreferredOrientations([
        DeviceOrientation.landscapeLeft,
        DeviceOrientation.landscapeRight,
      ]);
      break;
    case "세로 고정":
      SystemChrome.setPreferredOrientations([
        DeviceOrientation.portraitUp,
        DeviceOrientation.portraitDown,
      ]);
      break;
    default:
      // 자동
      SystemChrome.setPreferredOrientations([
        DeviceOrientation.landscapeLeft,
        DeviceOrientation.landscapeRight,
        DeviceOrientation.portraitUp,
        DeviceOrientation.portraitDown,
      ]);
      break;
  }

 

 

2024-05-28-화 : 상단 시스템 네비게이션이 계속 표출되는 경우

Scaffold의 AppBar()가 있으면 해결된다.

따로 ChromeSystemUI를 건드려도 초기 상단 시스템 네비게이션은 사라지지 않는다.

 

그래서 자연스럽게 SplashScreen에서 빈 AppBar()를 선언해주고 다음으로 넘어가면 자연스럽다

728x90
반응형

'dev > flutter' 카테고리의 다른 글

[Flutter] Geolocator #location  (0) 2024.02.21
[Flutter] CustomPainter  (0) 2024.02.14
[Flutter] Lifecycle  (1) 2024.02.07
[Flutter] FutureBuilder  (0) 2024.02.02
[Flutter] Youtube  (0) 2024.02.02