buildItem method
Implementation
@override
Widget buildItem(BuildContext context, ContextMenuItem item) {
return ButtonTheme.fromButtonThemeData(
data: ButtonTheme.of(context).copyWith(
height: kMinInteractiveDimension,
minWidth: kMinInteractiveDimension,
padding: EdgeInsets.symmetric(horizontal: 20)),
child: FlatButton(
onPressed: item.onPressed != null
? () {
final controller = DefaultContextMenuController.of(context);
final shouldHide = item.onPressed();
if (shouldHide) controller.hide();
}
: null,
padding: EdgeInsets.only(
// These values were eyeballed to match the native text selection menu
// on a Pixel 2 running Android 10.
top: 9.5,
bottom: 9.5,
left: 20,
right: 20,
),
shape: Border.all(width: 0.0, color: Colors.transparent),
child: item.title),
);
}