How to get AppBar height in Flutter?

前端 未结 10 1904
长发绾君心
长发绾君心 2020-12-14 14:50

How can I get the height of an AppBar in Flutter?
I am using the MarialApp Widget (\'package:flutter/material.dart\').

I have the height of my C

10条回答
  •  情书的邮戳
    2020-12-14 15:50

    Use preferred size

    //defined as
    Size preferredSize
    

    preferred size is a size whose height is the sum of kToolbarHeight and the bottom widget's preferred height.

    Scaffold uses this size to set its app bar's height.

    It is defined like below in app bar class which implement PreferredSizeWidget

     preferredSize = new Size.fromHeight(kToolbarHeight + (bottom?.preferredSize?.height ?? 0.0))
    

    a link for example ...

    https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/material/app_bar.dart

提交回复
热议问题