Я хотел бы добавить кнопку, по которой щелкнули, в список, но я не знаю, как получить доступ к самой нажатой кнопке.
Это мой текущий список кнопок . Создано с помощью:
for (var stand in stands) StandCreation(stand)
Это список, который я хочу заполнить:
List<String||Widget> SelectedStandList = []
Вот как я создаю каждую кнопку ':
import 'package:flutter/material.dart';
class StandCreation extends StatelessWidget {
final String stand;
StandCreation(this.stand);
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {}, // Here i would like to do something like SelectedStandList.add(tappedInkWell)
child: Container(
width: double.infinity,
margin: const EdgeInsets.only(
top: 5,
bottom: 5,
),
padding: const EdgeInsets.all(3.0),
color: Colors.blue,
child: Text(
stand,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 23,
fontWeight: FontWeight.bold,
),
),
),
);
}
}
Со списком я хочу затем создать новый экран только выбранных элементов. Ценю любую помощь!