buttonMenu method
Widget
buttonMenu({
- Key? key,
- List<
T> ? items, - PopupMenuItemBuilder<
T> ? itemBuilder, - T? initialValue,
- PopupMenuItemSelected<
T> ? onSelected, - PopupMenuCanceled? onCanceled,
- String? tooltip,
- double? elevation,
- EdgeInsetsGeometry? padding,
- Widget? child,
- Widget? icon,
- Offset? offset,
- bool? enabled,
- ShapeBorder? shape,
- Color? color,
- bool? captureInheritedThemes,
Implementation
// Returning a widget allows for the Builder() widget below.
Widget buttonMenu({
Key? key,
List<T>? items,
PopupMenuItemBuilder<T>? itemBuilder,
T? initialValue,
PopupMenuItemSelected<T>? onSelected,
PopupMenuCanceled? onCanceled,
String? tooltip,
double? elevation,
EdgeInsetsGeometry? padding,
Widget? child,
Widget? icon,
Offset? offset,
bool? enabled,
ShapeBorder? shape,
Color? color,
bool? captureInheritedThemes,
}) {
// So to retrieve the Scaffold object if any.
return Builder(builder: (context) {
this.context ??= context;
items ??= this.items;
Widget popupMenu = PopupMenuButton<T>(
key: key ?? this.key,
itemBuilder: itemBuilder ??
(items != null && items!.isNotEmpty
? _onItems(items)
: this.itemBuilder) ??
onItemBuilder,
initialValue: initialValue ?? this.initialValue ?? onInitialValue(),
onSelected: onSelected ?? this.onSelected ?? onSelection,
onCanceled: onCanceled ?? this.onCanceled ?? onCancellation,
tooltip: tooltip ?? this.tooltip ?? onTooltip(),
elevation: elevation ?? this.elevation ?? onElevation(),
padding:
padding ?? this.padding ?? onPadding() ?? const EdgeInsets.all(8),
icon: icon ?? this.icon ?? onIcon(),
offset: offset ?? this.offset ?? onOffset() ?? Offset.zero,
enabled: enabled ?? this.enabled ?? onEnabled() ?? true,
shape: shape ?? this.shape ?? onShape(),
color: color ?? this.color ?? onColor(),
child: child ?? this.child ?? onChild(),
);
// If not running under the MaterialApp widget.
if (context.widget is! Material &&
context.findAncestorWidgetOfExactType<Material>() == null) {
popupMenu = Material(child: popupMenu);
}
return popupMenu;
});
}