get height of a Widget using its GlobalKey in flutter

前端 未结 2 748
夕颜
夕颜 2020-12-28 11:28

I am struggling getting the height of a Widget using its GlobalKey. the function that is getting the height is called after the Layout is rendered to make sure the context i

2条回答
  •  借酒劲吻你
    2020-12-28 12:10

    Define your constructor like this:

    const MyWidget(GlobalKey key) : super(key:key);.

    The framework stores the BuildContext and State object in the Widget.key field which is passed into the object by constructor instead of an arbitary key field.

提交回复
热议问题