Я пытаюсь использовать onTap в Inkwell для открытия/предварительного просмотра существующей карты, но не знаю, как это сделать, пока я просто печатаю «привет»
body: Container(
color: Colors.indigo,
child: Column(
children: <Widget>[
Flexible(
child: FirebaseAnimatedList(
query: databaseReference,
itemBuilder: (
_, DataSnapshot snapshot,
Animation<double> animation, int index) {
return Card(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: InkWell(
child: ListTile(
title: Text(
boardMessages[index].subject,
style: TextStyle(fontWeight: FontWeight.bold
),),
),
onTap: (){
print('hello');
},
),
),
);
},
),
),
],
),
Обновлено: я знаю, как это сделать с помощью полноэкранной страницы благодаря предоставленным документам, как мне это сделать с помощью диалогового окна? Очень признателен
полноэкранная страница ;)
Здесь у вас есть дополнительная информация flutter.dev/docs/development/ui/navigation
Над вашим элементом ящика onTap сделайте следующее:
onTap: () {
Navigator.pop(context);
_showDialog(text: 'Index $index');
}
И используйте следующий код, чтобы отобразить диалоговое окно с необходимым текстом:
void _showDialog({@required String text}) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4),
),
elevation: 0,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 20,
vertical: 10,
),
child: IntrinsicWidth(
child: IntrinsicHeight(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 10,
),
Text(
"Custom Alert Dialog",
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 18,
),
),
SizedBox(
height: 20,
),
Text(
text,
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 16,
),
),
SizedBox(
height: 20,
),
Align(
alignment: Alignment.bottomRight,
child: FlatButton(
onPressed: () {
Navigator.pop(context);
},
child: Text("OK"),
),
),
],
),
),
),
),
);
},
);
Если полностью настраиваемый с любыми потребностями, которые у вас были.
это зависит от того, что вам нужно, вам нужен диалог или полноэкранная страница?