pickGridValue<T> static method
Future<T?>
pickGridValue<T>(
- List<
T> items, { - T? selected,
- Widget onItemView(
- T
- Widget? onTitle(
- T
- Widget? onHeader(
- T
- int columnCount = 0,
- double itemWidth = 80,
- double? itemHeight,
- double aspectRatio = 1.0,
- double verticalSpacing = 0.0,
- double horizontalSpacing = 0.0,
- EdgeInsets? padding,
- String? title,
- bool ok = false,
- bool cancel = false,
- DialogWidth? dialogWidth,
- List<
Widget> ? aboveWidgets, - List<
Widget> ? belowWidgets, - Alignment? dialogAlignment,
- EdgeInsets? dialogInsets,
Implementation
static Future<T?> pickGridValue<T>(
List<T> items, {
T? selected,
Widget Function(T)? onItemView,
Widget? Function(T)? onTitle,
Widget? Function(T)? onHeader,
Widget? Function(T)? onFooter,
int columnCount = 0,
double itemWidth = 80,
double? itemHeight,
double aspectRatio = 1.0,
double verticalSpacing = 0.0,
double horizontalSpacing = 0.0,
EdgeInsets? padding,
String? title,
bool ok = false,
bool cancel = false,
DialogWidth? dialogWidth,
List<Widget>? aboveWidgets,
List<Widget>? belowWidgets,
Alignment? dialogAlignment,
EdgeInsets? dialogInsets,
}) async {
return await showDialogX((b) {
b.init(result: selected);
return b.buildGrid(
items,
columnCount: columnCount,
itemWidth: itemWidth,
itemHeight: itemHeight,
aspectRatio: aspectRatio,
verticalSpacing: verticalSpacing,
horizontalSpacing: horizontalSpacing,
padding: padding,
builder: (iic) {
T item = iic.item;
Widget cell;
if (onItemView != null) {
cell = onItemView(item);
} else {
bool checked = b.result == item;
cell = GridTile(
header: onHeader?.call(item),
footer: onFooter?.call(item),
child: onTitle?.call(item) ?? item.toString().text(style: b.context.themeData.textTheme.titleMedium).centered(),
).let((e) {
if (!checked) return e;
return e.coloredBox(b.gridSelectedBackground).clipRoundRect(3);
});
}
return cell.inkWell(onTap: () {
b.setResult(item);
if (ok == true) {
b.updateState();
} else {
b.clickOK();
}
});
},
title: title,
ok: ok,
cancel: cancel,
dialogWidth: dialogWidth,
aboveWidgets: aboveWidgets,
belowWidgets: belowWidgets,
);
}, alignment: dialogAlignment, insetPadding: dialogInsets);
}