TextField 有一个很好的方法来在它的 BoxDecoration 装饰上放置一个文本标签,如下:
通过以下方式:
有没有办法在 Container 的其他 BoxDecoration 上实现同样的效果?例如,我想指定标签"XP":
但是 Flutter 没有为 BoxDecoration 提供 labelText (仅存在于 InputDecoration )。
我们可以使用 InputDecorator 作为父对象来完成上述需求,如下:
输出
TextField 有一个很好的方法来在它的 BoxDecoration 装饰上放置一个文本标签,如下:
通过以下方式:
有没有办法在 Container 的其他 BoxDecoration 上实现同样的效果?例如,我想指定标签"XP":
但是 Flutter 没有为 BoxDecoration 提供 labelText (仅存在于 InputDecoration )。
我们可以使用 InputDecorator 作为父对象来完成上述需求,如下:
输出