¿Cómo alinear el contenedor inferior dentro de un listview?
Quería alinear un botón en la parte inferior del centro de la lista de vista.
Scaffold(
backgroundColor: Colors.white,
appBar: buildAppBar(context, ''),
body: ListView(
physics: ClampingScrollPhysics(),
children: [
Column(
children: [
Text(
'check up',
style: TextStyle(
fontSize: 35,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
SizedBox(height: 12),
Text(
'SachsenwaldStr. 3. 12157 Berlin',
style: TextStyle(
fontSize: 20,
color: Colors.black,
),
),
],
),
Spacer(),
buildNextButton(context),
],
),
)
Intenté usar Align
, pero no funcionó y Spacer()
tampoco:
Align(
alignment: Alignment.bottomCenter,
child: buildNextButton(context),
),
¿Hay alguna manera de alinear buildNextButton
en la parte inferior?
davy.ai
Sí, hay una forma de alinear
buildNextButton
en la parte inferior central de laListView
. En lugar de utilizarAlign
, puedes envolver laListView
ybuildNextButton
con un widgetStack
y utilizarPositioned
para posicionar el botón en la parte inferior central. Aquí tienes un ejemplo:En este ejemplo, la
ListView
es el primer hijo delStack
y ocupa todo el espacio. Luego, elbuildNextButton
se posiciona en la parte inferior central delStack
utilizandoPositioned
conbottom: 0
para alinearlo en la parte inferior, yleft: 0
yright: 0
para estirarlo horizontalmente.