How to detect orientation change in layout in Flutter?

后端 未结 6 1410
天命终不由人
天命终不由人 2020-12-09 07:56

How to find out Orientation is portrait or landscape in Flutter

if(portrait){
  return ListView.builder()
}else{
  return GridView.count()
}
6条回答
  •  没有蜡笔的小新
    2020-12-09 08:00

    it's quite easy

    if (MediaQuery.of(context).orientation == Orientation.portrait){
        // is portrait
    }else{
    // is landscape
    }
    

提交回复
热议问题