PopupMenuButton<T> constructor Null safety

const PopupMenuButton<T>(
  1. {Key? key,
  2. required PopupMenuItemBuilder<T> itemBuilder,
  3. T? initialValue,
  4. VoidCallback? onOpened,
  5. PopupMenuItemSelected<T>? onSelected,
  6. PopupMenuCanceled? onCanceled,
  7. String? tooltip,
  8. double? elevation,
  9. Color? shadowColor,
  10. Color? surfaceTintColor,
  11. EdgeInsetsGeometry padding = const EdgeInsets.all(8.0),
  12. Widget? child,
  13. double? splashRadius,
  14. Widget? icon,
  15. double? iconSize,
  16. Offset offset = Offset.zero,
  17. bool enabled = true,
  18. ShapeBorder? shape,
  19. Color? color,
  20. bool? enableFeedback,
  21. BoxConstraints? constraints,
  22. PopupMenuPosition? position,
  23. Clip clipBehavior = Clip.none}
)

Creates a button that shows a popup menu.

The itemBuilder argument must not be null.

Implementation

const PopupMenuButton({
  super.key,
  required this.itemBuilder,
  this.initialValue,
  this.onOpened,
  this.onSelected,
  this.onCanceled,
  this.tooltip,
  this.elevation,
  this.shadowColor,
  this.surfaceTintColor,
  this.padding = const EdgeInsets.all(8.0),
  this.child,
  this.splashRadius,
  this.icon,
  this.iconSize,
  this.offset = Offset.zero,
  this.enabled = true,
  this.shape,
  this.color,
  this.enableFeedback,
  this.constraints,
  this.position,
  this.clipBehavior = Clip.none,
}) : assert(itemBuilder != null),
     assert(enabled != null),
     assert(
       !(child != null && icon != null),
       'You can only pass [child] or [icon], not both.',
     );