Giter VIP home page Giter VIP logo

popup_menu's Introduction

pub package

This project was writed with pure dart code,which means it's support both iOS and Android.

Screenshot

Todo

  • show/hide animation

Usage

You can find the demo at the 'example' folder.

First, you should set the context at somewhere in you code. Like below:

PopupMenu.context = context;
PopupMenu menu = PopupMenu(
      items: [
        MenuItem(title: 'Copy', image: Image.asset('assets/copy.png')), 
        MenuItem(title: 'Home', image: Icon(Icons.home, color: Colors.white,)), 
        MenuItem(title: 'Mail', image: Icon(Icons.mail, color: Colors.white,)), 
        MenuItem(title: 'Power', image: Icon(Icons.power, color: Colors.white,)),
        MenuItem(title: 'Setting', image: Icon(Icons.settings, color: Colors.white,)), 
        MenuItem(title: 'Traffic', image: Icon(Icons.traffic, color: Colors.white,))], 
      onClickMenu: onClickMenu, 
      onShow: onShow,
      onDismiss: onDismiss);

menu.show(rect: rect);

or

PopupMenu menu = PopupMenu(
        backgroundColor: Colors.teal,
        lineColor: Colors.tealAccent,
        maxColumn: 3,
        items: [
          MenuItem(title: 'Copy', image: Image.asset('assets/copy.png')),
          MenuItem(
              title: 'Home',
              textStyle: TextStyle(fontSize: 10.0, color: Colors.tealAccent),
              image: Icon(
                Icons.home,
                color: Colors.white,
              )),
          MenuItem(
              title: 'Mail',
              image: Icon(
                Icons.mail,
                color: Colors.white,
              )),
          MenuItem(
              title: 'Power',
              image: Icon(
                Icons.power,
                color: Colors.white,
              )),
          MenuItem(
              title: 'Setting',
              image: Icon(
                Icons.settings,
                color: Colors.white,
              )),
          MenuItem(
              title: 'PopupMenu',
              image: Icon(
                Icons.menu,
                color: Colors.white,
              ))
        ],
        onClickMenu: onClickMenu,
        onDismiss: onDismiss);
    menu.show(widgetKey: btnKey2);

popup_menu's People

Contributors

chinabrant avatar creky avatar muriloventuroso avatar nicorobine avatar oozd avatar wushujun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

popup_menu's Issues

I have this error

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

Close menu on gestures

Thanks a whole lot for your quick responses and dedication to this project. I would suggest an improvement of closing the popup menu if other gestures like swipe/scroll (on page) occurs. This is because the menu only closes if a user taps on the menu item or outside the menu but not other gestures (like scroll through a list the menu still remains open).
Thanks

The itemWidth setting caused a width error

Regarding the itemWidth in MenuConfig, this setting will not be synchronized to the grid type itemWidth after external modifications, as the itemWidth in MenuConfig was not passed to the GridLayout. Modifying the itemWidth will affect the overall width, but it will not change the width of each item because you have written the item width to 72

menu wont show

The method 'findRenderObject' was called on null.
Receiver: null
Tried calling: findRenderObject()

offset.x is not suitable on somecase.

The 'menu content' is a Positioned component, and it center.x was equals parent widget's center.x, so when parent's postion is closer to screen's right side, set Positioned's left = offset.dx will cause a part of menu content is hidden. I already change code to left = 10 on my project and feel better.

Last line of the menu is not drawn

Hi,
I'm creating a menu as follows:

                        PopupMenu menu = PopupMenu(
                            maxColumn: 6,
                            lineColor: Colors.grey,
                            items: repository.getAllUsers().map((e) => MenuItem(
                                title: repository.getUserNameForId(e.id),
                            )).toList(),
                            onClickMenu: (item) {

                            }
                        );
                        menu.show(widgetKey: key);

But the last line is not drawn. Please see attached:
Screen Shot 2020-10-07 at 17 10 32

This error occurs when creating all number of column number

Please advise

menuWidth & menuHeight

建议pop框的menuWidth宽,menuHeight高都写成开放的属性,在外部可以直接修改宽高属性。

Listen to menu state

Hi, really love your package but there's no available method or functionality to listen to the open and close state of the popup menu in order to dynamically open or close the menu when required? Thanks

Multiple widgets used the same GlobalKey.

This error occur when try to showPopup with ListView.builder

  ListView.builder(
        itemCount: list.length,
        itemBuilder: (context, index) {
         return MaterialButton(
            key:  btnKey,
            child: ListTile(
              title: Text("Title"),
              subtitle: Text("Title"),
              onTap: showPopup,
            ),
            onPressed: showPopup,
          );
        },
      )

demo caused an exception in dismiss function

flutter: menu is showing
flutter: Menu is dismiss
flutter: menu is closed
flutter: ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
flutter: The following assertion was thrown while handling a gesture:
flutter: 'package:flutter/src/widgets/overlay.dart': Failed assertion: line 133 pos 12: '_overlay != null':
flutter: is not true.
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #2 OverlayEntry.remove (package:flutter/src/widgets/overlay.dart:133:12)
flutter: #3 PopupMenu.dismiss (package:popup_menu/popup_menu.dart:329:12)
flutter: #4 PopupMenu.buildPopupMenuLayout.. (package:popup_menu/popup_menu.dart:157:11)
flutter: #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
flutter: #6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:365:11)
flutter: #7 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:312:7)
flutter: #8 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)

offset is wrong when arrow down

fixed:

Offset _calculateOffset(BuildContext context) {
double dx = _showRect.left + _showRect.width / 2.0 - menuWidth() / 2.0;
if (dx < 10.0) {
dx = 10.0;
}

double dy = _showRect.top - menuHeight();
if (dy <= MediaQuery.of(context).padding.top + 10) {
  // The have not enough space above, show menu under the widget.
  dy = arrowHeight + _showRect.height + _showRect.top;
  _isDown = false;
} else {
  /// #######需要加上这行代码,修复三角形的高度
  dy -= arrowHeight; 
  _isDown = true;
}

return Offset(dx, dy);

}

userInfo missing in MenuItemProvider

The MenuItem has the userInfo property

MenuItem({this.title, this.image, this.userInfo, this.textStyle});

However this is missing in the OnClick.. MenuItemProvider

  void onPopMenuClick(MenuItemProvider item) {

    if (item.userIfno == "Note"){ \\ <<<<<<< MISSING......
      Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => NoteScreen(job_id: this.job.job_id, sys_track_id: 0,),
                ),
              );
    }

  }

呼出菜单位置偏移

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.18363.720], locale zh-CN)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.6)
[√] Connected device (1 available)

• No issues found!

——————————
呼出菜单会出现在页面左上角而不是在点击的widget上,context和key都使用了。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.