一、为组件设置key
GlobalKey _appbarKey = new GlobalKey();
AppBar(key: _appbarKey ,...)
二、获取组件的宽高
getSize() {
RenderBox? renderBox = _appbarKey.currentContext?.findRenderObject() as RenderBox;
print(renderBox.size.height); // 组件高
print(renderBox.size.width); // 组件宽
}