[Flutter] OrientationBuilder

CHOI·2021년 12월 5일
1

[Flutter] 위젯

목록 보기
1/6
post-thumbnail

OrientationBuilder 란?

OrientationBuilder 화면을 회전할때마다 다른 UI를 보여주거나 다른 값을 보여주고 싶을때 사용하는 widget 입니다.

Code

class OrientationBuilderExample extends StatelessWidget {
  const OrientationBuilderExample({Key? key}) : super(key: key);

  
  Widget build(BuildContext context) {
    return Scaffold(
      body: OrientationBuilder(
        builder: (context, orientation) {
          return Text('화면 회전 감지: ${orientation.toString()}');
        },
      ),
    );
  }
}

Orientation 값

orientation.portrait: 가로 방향
orientation.landscape: 세로 방향


자료 출처

OrientationBuilder class
Update the UI based on orientation

profile
Mobile App Developer

0개의 댓글