Flutter-在横向模式下全屏显示地图

时间:2018-12-10 08:51:08

标签: dart flutter

我正在尝试为纵向和横向创建不同的界面。在纵向模式中,我们有一些按钮和选项,但是在使用横向模式时,我们只能看到完整尺寸的地图。

默认方向为纵向,因此我们可以看到按钮和选项。我需要检测用户何时更改为陆地空间以显示其他元素。

我尝试使用此代码,但是没有用,没有检测到屏幕方向。

    Orientation orientation = MediaQuery.of(context).orientation ;
      if (orientation == Orientation.landscape) {
            return new Scaffold(body: map);
          } else {
            return new Scaffold(
    body: BUTTONS
);

那我该如何检测方向?

更新2 无效,没有检测方向变化。

 if (loading) {
      return Scaffold(key: scaffoldKey, body: indicator);
    } else {
      return new OrientationBuilder(
  builder: (context, orientation) {
         return new Scaffold(
            key: scaffoldKey,
            body: orientation==Orientation.landscape ? new Row(children: <Widget>[map]):
  new Column(
              children: <Widget>[
                parcelSearch,
                new Expanded(
                  child: new Center(
                    child: new Container(
                      child: new Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: new Card(
                          child: ListView(
                            children: <Widget>[
                              metersElement,
                              valvesElement,
                              relesElement,
                              sensorsElement,
                            ],
                          ),
                        ),
                      ),
                    ),
                  ),
                ),
                map,
                estateDropdown,
              ],
            ));
      });
      } 

0 个答案:

没有答案
相关问题