chinabrant / popup_menu

🔥A flutter popup menu. Pub enabled.
https://pub.dev/packages/popup_menu
Other
442 stars 136 forks source link

I have this error #31

Open ninjai001 opened 4 years ago

ninjai001 commented 4 years ago

package:flutter/src/widgets/media_query.dart': Failed assertion: line 819 pos 12: 'context != null': is not true c

function1983 commented 3 years ago

Try passing in BuildContext of the parent widget

GestureDetector(
    key: btnKey,
    onTap: () => customBackground(btnKey, context),
    child: Container()
)
void customBackground(GlobalKey btnKey, BuildContext mainContext) {
    menu.dismiss();
    menu = PopupMenu(
      context: mainContext,
      items: [
          MenuItem(
              title: 'Mail',
              image: Icon(
                Icons.mail,
                color: Colors.white,
              )),
        ],
        onClickMenu: onClickMenu,
        stateChanged: stateChanged,
        onDismiss: onDismiss);
    menu.show(widgetKey: btnKey);
}