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

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

///  * [kMinInteractiveDimensionCupertino]
///  * The Material spec on touch targets at .
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(),
    )

你可能感兴趣的:(flutter,android,android,studio)