【发布时间】:2020-11-01 00:23:02
【问题描述】:
我在堆栈小部件中定位(使用对齐)两个子小部件,其中一个包含表单 TextField 以获取输入。当我点击输入数据时,只有它的父小部件在键盘上向上移动,如下图所示。 从键盘输入数据时,有什么方法可以移动/调整堆栈的子小部件的大小。
源代码:
return Scaffold(
body: Stack(
children: <Widget>[
Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/playingboard2.jpg'),
fit: BoxFit.cover)),
child: null,
),
_buildSelfPlayer(), // Returns the widget with form input and other widgets
_buildBank(), // top center, shows two pictures of bank
],
),
);
【问题讨论】:
-
您是否尝试将
Stack包裹在具有垂直滚动方向的SingleChildScrollView中? -
是的,我试过了,然后所有的小部件都失去了对齐并在顶部中心堆积。