【问题标题】:How to get the width and height of AlertDialog - Flutter Web如何获取 AlertDialog 的宽高 - Flutter Web
【发布时间】:2021-08-26 16:48:13
【问题描述】:

我想在 Flutter 中获得 AlertDialog 的确切高度和宽度。

【问题讨论】:

    标签: android flutter flutter-web flutter-alertdialog


    【解决方案1】:

    我不明白你的目的是什么,而是指定一个尺寸来测量它。

    在警报对话框的上下文中,您可以在其中放置其他组件,使用以下内容。使用以下代码,您可以获得您认为是上下文的 UI 组件内的测量值。

    alert_dialog_height=MediaQuery.of(context).size.height; alert_dialog_width=MediaQuery.of(context).size.width;

    如果您需要在警报对话框的中间高度放置一些东西,只需使用

    alert_dialog_height/2
    

    【讨论】:

      猜你喜欢
      • 2019-05-23
      • 2021-07-31
      • 2021-08-26
      • 2019-12-09
      • 2023-02-09
      • 2015-08-01
      • 2021-01-02
      • 1970-01-01
      • 2012-08-05
      相关资源
      最近更新 更多