popupMenu<T> static method

Widget popupMenu<T>(
  1. BuildContext context,
  2. List<T> items,
  3. PopupMenuItemSelected<T> onSelect,
  4. Widget child,
  5. IndexedWidgetBuilder itemBuilder, {
  6. double? offsetY,
  7. double? height,
  8. double? itemWidth,
  9. EdgeInsets? padding,
  10. PopupMenuPosition? position,
  11. Color? bgColor,
})

Implementation

static  Widget popupMenu <T>(BuildContext context, List<T> items,
    PopupMenuItemSelected<T> onSelect, Widget child, IndexedWidgetBuilder itemBuilder, {double? offsetY,
      double? height, double? itemWidth, EdgeInsets? padding, PopupMenuPosition? position,
      Color? bgColor} ){
  return PopupMenuButton<T>(
    position: position ?? PopupMenuPosition.under,
    constraints: BoxConstraints(
      minWidth: itemWidth ?? 120,
      maxWidth: itemWidth ?? 120,
    ),
    padding: EdgeInsets.zero,
    surfaceTintColor: bgColor ?? Theme.of(context).dialogBackgroundColor,
    shadowColor: bgColor ?? Theme.of(context).dialogBackgroundColor,
    offset: Offset(0, offsetY??0),
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(5),
    ),
    color: bgColor ?? Theme.of(context).dialogBackgroundColor,
    onSelected: onSelect,
    itemBuilder: (builder) => items.map((e) => PopupMenuItem<T>(
      padding: EdgeInsets.zero,
      height: height ?? 36,
      value: e!,
      child: itemBuilder(context, items.indexOf(e)),
    )).toList() ,child: child,);
}