menu

pub package GitHub

menu with flutter

just wrap your widget ,and long tap to show menu

like this:

Screenshot_2019-05-23-10-58-43-361_com.example.ex.png

Usage

import 'package:menu/menu.dart';

Menu(
  child: Container(
    width: 200,
    color: Colors.yellow,
    height: 100,
    child: Text("long press show menu"),
  ),
  items: [
    MenuItem("copy", () {}),
    MenuItem("add", _incrementCounter),
  ],
  decoration: MenuDecoration(
    itemConstraints: BoxConstraints(),
  ),
);

params

NameTypeRequiredDescribe
childWidgettruewidget
itemsListtrueoptions
decorationMenuDecorationfalsedecoration for menu and item
itemBuilderItemBuilderfalsecustomItem
clickTypeClickTypefalse
dividerBuilderDivderBuilderfalsebuild divider builder

typedef Widget DividerBuilder(BuildContext context, int lastIndex);

NameTypeRequiredDescribe
textstringtrue
onTapFunctiontrueonTap
NameTypeRequiredDescribeDefault
textStyleTextStylefalsestyle of menu itemTextStyle(fontSize: 14.0,color: Colors.white)
colorColorfalsecolor of menu itemColor(0xFF111111)
splashColorColorfalsesplashColor of menu itemColor(0xFF888888)
radiusdoulefalseradius of menu item, only first and last item5.0
constraintsBoxConstraintsfalseconstraints of menu itemBoxConstraints()
paddingTextStylefalsepadding of menu item'textEdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0)

ClickType

NameDescribe
clickclick to show menu
longPresslongPress widget to show menu
doubleClickdouble click widget to show menu
noneNot responding to touch events

Libraries