如何调整 Flutter 表日历的大小

Mic*_*sov 3 dart flutter

颤振新手。我需要显示一个日历和下面的一些内容,所以我需要使日历更小。我尝试过使用这样的 SizedBox:

Column(
  children: [
    SizedBox(
      height: 500,
      child: TableCalendar(
        firstDay: firstDay,
        lastDay: lastDay,
        focusedDay: focusedDay)),
    Text("Content goes \n\n\n\n\n\n\n\n\n\n\n\n\n\n\nhere")
  ],
),
Run Code Online (Sandbox Code Playgroud)

但这只是剪辑它。如何正确调整日历的大小?

更新: FittedBox 不起作用,如果您输入宽度,它会正确调整大小,但高度仍然只是剪辑

Nis*_*ddy 6

我浏览了他们的源代码,发现shouldFillViewport它可以解决您的用例。

您还需要将您的内容包装TableCalendar在一个Expanded小部件内。

 Column(
    children: [
      Expanded(
        child: SizedBox(
          height: 500,
          width: 300,
          child: TableCalendar(
              shouldFillViewport: true,
              firstDay: DateTime(2020),
              lastDay: DateTime(2021),
              focusedDay: DateTime(2020),
        ),
      ),
      Text("Content goes \n\n\n\n\n\n\n\n\n\n\n\n\n\n\nhere")
    ],
  ),
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述