加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

颤振的景观方向布局

发布时间:2020-12-14 14:52:18 所属栏目:百科 来源:网络整理
导读:如何在横向模式下设置AppBar高度,以便它不占用屏幕填充? 是否有通常的Flutter景观布局小工具?上述问题布局如下: new Padding( padding: media.padding,child: new Scaffold( key: _scaffoldKey,body: new Row( children: Widget[ new LimitedBox( maxWidt
如何在横向模式下设置AppBar高度,以便它不占用屏幕填充?

enter image description here

是否有通常的Flutter景观布局小工具?上述问题布局如下:

new Padding(
  padding: media.padding,child: new Scaffold(
      key: _scaffoldKey,body: new Row(
        children: <Widget>[
          new LimitedBox(
            maxWidth: 320.0,child: new Column(children: [
              _buildAppBar(),new Expanded(
                  child: new ModuleDrawer(
                widget.module.sugar,topPadding: 0.0,)),]),),new Expanded(
            child: new RecordList(
              widget.model,],)));

解决方法

你可以使用Scaffold的主要属性,结合通过简单的MediaQuery检测方向.因此,在横向模式下,将主标志设置为false,以告知脚手架在确定AppBar高度时不考虑状态栏高度.

见the documentation:

Whether this scaffold is being displayed at the top of the screen.

If true then the height of the appBar will be extended by the height of the screen’s status bar,i.e. the top padding for MediaQuery.

The default value of this property,like the default value of AppBar.primary,is true.

所以在你的情况下,这样的事情应该做:

@override
Widget build(BuildContext context) {
    final Orientation orientation = MediaQuery.of(context).orientation;
    final bool isLandscape = orientation == Orientation.landscape;

    return new Scaffold(
        primary: !isLandscape,appBar: new AppBar(
          title: new Text('AppBar title'),body: new Center(
            child: new Text('Look at the appbar on landscape!'),);
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读