简体   繁体   English

对话框中的卡片全屏显示

[英]A card inside a dialog occupies full screen

I am using a card inside a dialog. 我在对话框中使用卡片。 It occupies full screen even though the child of the card has a container widget of fixed width and height. 即使卡片的子代具有固定宽度和高度的容器小部件,它也会占据全屏。 I am using the below code: 我正在使用以下代码:

showDialog(context: context, builder: (context)
{
  return Card(
    clipBehavior: Clip.antiAlias,
    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
    elevation: 8.0,
    child: Container(
      width: MediaQuery.of(context).size.width * 0.80,
      height: 300,
      color: const Color(0xFF465A63)
    ),
  );
});

Wrap the Card in a size-constraining widget like SizedBox , FractionallySizedBox or Container . Card包装在大小受限制的小部件中,例如SizedBoxFractionallySizedBoxContainer Give it a certain size and position it on the screen using Center or Align . 设置一定的大小,然后使用CenterAlign其放在屏幕上。

By default the showDialog() method gives you the whole screen to compose a widget, not only the small window the AlertDialog() widget for example uses. 默认情况下, showDialog()方法为您提供整个屏幕来组成一个小部件,而不仅仅是AlertDialog()小部件使用的小窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM