1.获取状态栏高度
1.第一种,注意:这里需要导入 'dart:ui' 包
import 'dart:ui';
MediaQueryData.fromWindow(window).padding.top
2.第二种,
MediaQuery.of(context).padding.top
说到状态栏,就要说个安全区域的概念:所谓安全区域,就是适配现在一些刘海屏之类的非常规显示屏,在flutter中除了根据上面的方法获取到状态栏高度,给页面加对应的状态栏高度padding,还有一个专门的widget用来显示安全区域内容:SafeArea
2.获取appBar高度
位于 Dart Packages/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;
3.获取手机屏幕宽高
Material 设