Код: Выделить всё
Future itemPreviouslyBought(BuildContext context, Item newItem, AsyncValue currentItemList) {
return currentItemList.when(
data: (item) {
final matchedElement = item.firstWhere(
(element) =>
element.productName.toLowerCase() ==
newItem.productName.toLowerCase(),
);
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Item Previously Bought!'),
content: SingleChildScrollView(
child: ListBody(
children: [
Text("You have bought this item before."),
],
),
),
actions: [
TextButton(
child: const Text('Okay'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
},
loading: () => const Center(child: CircularProgressIndicator()),
error: (e, st) => Center(child: Text(e.toString())),
);
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... -asyncvalu