如何去掉SpinBox内容和下划线之间的space?

How to remove the space between SpinBox content and underline?

我的问题与 基本相同,只是我问的不是 TextFormField 小部件,而是 SpinBox 小部件。设置 isDense: trueisCollapsed: true 似乎使数字与 increment/decrement 按钮不一致(见屏幕截图)

与此同时,包裹在 SizedBox 中并设置高度是一些改进,但我无法像我想要的那样缩小高度,或者 increment/decrement 低于该线。 这是身高 25:

45 的高度在视觉上看起来不错,但它占用了太多 space 无法满足我的需要。

生成以下布局的当前代码:

SizedBox(
  width: 120,
  height: 45,
  child: SpinBox(
    value: 0,
    onChanged: (value) {}
  ),
)

查看 SpinBoxsource code 可以看到 TextFieldinputDecoration 已暴露,您可以尝试删除 contentPadding,看看它是否解决了您的问题:

SpinBox(
  decoration: InputDecoration(
    contentPadding: EdgeInsets.zero,
  ),
);