Flutter AppBar、BottomNavigationBar及状态栏的高度;屏幕宽高

本文介绍了如何在Flutter中调整AppBar和BottomNavigationBar的高度,遵循Material设计规范,同时讨论了状态栏高度的获取方法。还展示了如何动态设置AppBar的高度,以适应不同屏幕尺寸。
摘要由CSDN通过智能技术生成

1.AppBar、BottomNavigationBar 高度
flutter插件包位置:/flutter/src/material/constans.dart 中代码

///  * [kMinInteractiveDimensionCupertino]
///  * The Material spec on touch targets at <https://material.io/design/usability/accessibility.html#layout-typography>.
const double kMinInteractiveDimension = 48.0;
 
/// The height of the toolbar component of the [AppBar].
const double kToolbarHeight = 56.0;
 
/// The height of the bottom navigation bar.
const double kBottomNavigationBarHeight = 56.0;

2.状态栏高度
导入:import 'dart:ui';

MediaQueryData.fromWindow(window).padding.top

3.屏幕宽高

MediaQuery.of(context).size.width
MediaQuery.of(context).size.height

Material 设计规范中 状态栏、导航栏、ListTile高度分别为 24、56、56

4.动态设置appbar高度

Scaffold(
      appBar: PreferredSize(
        preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.07),
        child: Offstage(
          child: appbar('修改高度的AppBar', context,
              elevation: 0,
              backcolor: Colors.white,
              titleColor: ColorConfig.black,
              brigthess: Brightness.light),
          offstage: false,
        ),
      ),
      body: _body(),
    )
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值