Я ищу способ установить виджет в нижней части карты, я не знаю, должен ли я использовать этот виджет, но у меня есть следующий код:
Widget build(BuildContext context) {
return GridView.count(
primary: true,
padding: const EdgeInsets.all(20.0),
crossAxisSpacing: 1.0,
childAspectRatio: 1.5,
crossAxisCount: 1,
children: <Widget>[
Card(
child: new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const ListTile(
leading: const Icon(Icons.album),
title: const Text('The Enchanted Nightingale'),
subtitle: const Text('Music by Julie Gable. Lyrics by Sidney Stein.'),
),
new ButtonTheme.bar( // make buttons use the appropriate styles for cards
child: new ButtonBar(
children: <Widget>[
new FlatButton(
child: const Text('BUY TICKETS'),
onPressed: () { /* ... */ },
),
new FlatButton(
child: const Text('LISTEN'),
onPressed: () { /* ... */ },
),
],
),
),
],
),
)
]
);
}
Итак, я хочу добавить что-то вроде bottom: Text ('Я внизу')
Это то, что я хочу, виджет внизу и добавление в него детей. Буду признателен за помощь.
позвольте мне создать один
Я только что отредактировал пост с изображением
Еще одно предложение. Не имеет отношения к вашей проблеме. GirdView with crossAxisCount = 1
невероятно похож на ListView
Вы можете использовать виджет Expanded
, обертывающий ваш ListTile
@override
Widget build(BuildContext context) {
return Center(
child: Container(
child: GridView.count(
primary: true,
padding: const EdgeInsets.all(20.0),
crossAxisSpacing: 1.0,
childAspectRatio: 1.5,
crossAxisCount: 1,
children: <Widget>[
Card(
child: new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Expanded(
child: const ListTile(
leading: const Icon(Icons.album),
title: const Text('The Enchanted Nightingale'),
subtitle: const Text(
'Music by Julie Gable. Lyrics by Sidney Stein.'),
),
),
Container(
color: Colors.blue,
child: new ButtonBar(
children: <Widget>[
new FlatButton(
child: const Text('BUY TICKETS'),
onPressed: () {/* ... */},
),
new FlatButton(
child: const Text('LISTEN'),
onPressed: () {/* ... */},
),
],
),
)
],
),
)
])));
Я просто добавляю контейнер с произвольным цветом, чтобы увидеть нижнюю часть.
Я получил свое решение, используя Scaffold и потребляя свой собственный bottomNavigationBar.
Card(
child: Scaffold(
bottomNavigationBar: Text('This is my text'),
body: new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const ListTile(
leading: const Icon(Icons.album),
title: const Text('The Enchanted Nightingale'),
subtitle: const Text('Music by Julie Gable. Lyrics by Sidney Stein.'),
),
new ButtonTheme.bar( // make buttons use the appropriate styles for cards
child: new ButtonBar(
children: <Widget>[
new FlatButton(
child: const Text('BUY TICKETS'),
onPressed: () { /* ... */ },
),
new FlatButton(
child: const Text('LISTEN'),
onPressed: () { /* ... */ },
),
],
),
),
],
),
)
)
Я думал, что вы хотите, чтобы ваш виджет был элементом списка, иначе лучшим вариантом будет scaffold bottomNavigationBar.
у вас есть представление о том, чего вы хотите?