Custom menus anywhere!

Overview

Flutter Anywhere Menus (FAM) Pub Version

Menus, anywhere you want them!

Default Usage

Imgur

Menu(
  child: MaterialButton(
    child: Text('Show Basic Menu'),
  ),
  menuBar: MenuBar(),
),

Slightly Fancier Menu

Imgur

Menu(
  child: MaterialButton(
    child: Text('Dem Fancy Menus'),
  ),
  menuBar: MenuBar(
    drawArrow: true,
    itemPadding: EdgeInsets.symmetric(horizontal: 15, vertical: 4),
    menuItems: [
      MenuItem(
        child: Icon(Icons.color_lens, color: Colors.grey[600]),
        onTap: () => _incrementCounter(),
      ),
      MenuItem(
        child: Menu(
          offset: Offset(0, 20),
          child: Icon(Icons.colorize, color: Colors.grey[600]),
          menuBar: MenuBar(
              drawArrow: true,
              drawDivider: true,
              maxThickness: 68,
              orientation: MenuOrientation.vertical,
              menuItems: [MenuItem(child: Icon(Icons.add))]),
        ),
      ),
      MenuItem(
          child: Icon(Icons.content_copy, color: Colors.grey[600])),
    ],
  ),
),

Menu On Tap

Imgur

Menu(
  tapType: TapType.tap,
  child: Container(
    width: 300,
    height: 200,
    color: Colors.yellow,
    child: Center(child: Text('Show Menu Over Tap')),
  ),
  menuOverTap: true,
  menuBar: menuBar,
),

Roadmap

  • Vertical menus
  • Animations
  • Fixed screen position menus (Guess that'd just be a Toast...)

Background

Why FAM? The short answer is... yak shaving. I needed a menu for a project that would pop up above a widget when I clicked on it. Simple right? Yeah... no. There were a few more requirements that made it a far more interesting problem.

  1. The menu needs to be very customizable
  2. The menu needs the ability to have child menus OR child widgets
  3. The menu (and all children) needs to be a drawn above all other widgets
  4. And this was the doozy... the menu needs to be positionable RELATIVE to its parent widget, and all child menus and child widgets need to be relative positioned to their parent

That last requirement took me down the rabbit hole of Flutter widget positioning and long story short, Flutter is one of a few (maybe the only?) rendering/UI languages I've used that simply cannot do relative positioning out of the box (pun intended). See, the box is what traps you. You can Column() and Row() all day long but you're still trapped in box. What I want is the equivalent of widget1.alignTo(widget2, fromAlignment: Alignment.topCenter, toAlignment: Alignment.bottomCenter) so that I can setup a widget and then just stick it on to another widget. A man can dream right?

Maybe Stack() and Align()? HA! Still stuck in that box, and still no way to define a solid widget-to-widget positioning.

I want my menu outside of the box MAN! And without knowing the sizes of the boxes before rendering, good luck trying to accurately position a menu over (or under, or next to) its intended target widget. So what does FAM do?

It... cheats.

FAM still doesn't know about the properties of the menu before hand, BUT what it can do is render the menu invisibly as an overlay, examine its size, then move it to where it needs to be. The result is that I can now define an absolute relationship between relevant points on a widget (say, tying the bottomCenter of one widget to the topCenter of another) without either widget having any relationship, and without any restrictions on how I draw either widget, while making sure that whatever crazy alignments I do won't mess up the positioning or size of my original widget.

OK. It ain't pretty, but the results do speak for themselves. Hope at least some of you can make use of this, and maybe Flutter will one day have relational positioning like any sensible rendering language.

Credits

This was originally a fork of https://github.com/CaiJingLong/flutter_long_tap_menu that outgrew most of the original code. Many yak were shaved in the process.

You might also like...

Arisslidetransition - Create your own custom SlideTransition combined with some animation in Flutter

Arisslidetransition - Create your own custom SlideTransition combined with some animation in Flutter

SlideTransition Animation - Flutter Create your own custom SlideTransition combi

Jan 9, 2022

Flutter-context-menus - A flutter package to show context menus on right-click or long-press

context_menus A package to show context menus on right-click or long-press. 🔨 I

Jan 18, 2022

Resor is based on an online ordering system instead of traditional paper menus in restaurants

Resor is based on an online ordering system instead of traditional paper menus in restaurants

Resor Restaurant Order App Resor is based on an online ordering system instead of traditional paper menus in restaurants. The online ordering system h

Nov 13, 2022

This is a package which helps we can start loader from anywhere of our code.

This is a package which helps we can start loader from anywhere of our code.

global_loader A Flutter Package which will start Global Loader from any where in your code. Screenshots Usage Example To use this package: add the dep

Dec 23, 2021

Returns a list of universities in Nigeria and can be used anywhere

naija_uni Returns a list of universities in Nigeria and can be used anywhere. Drop Down it can be used in a dropdown to prompt easy selection Dropdown

Jan 16, 2022

A password manager which can be accessed from anywhere.

pssswd A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this i

Jun 20, 2022

best flutter / dart practices + Custom Painter + Sliver App Bar + Custom Scrollview

best flutter / dart practices + Custom Painter + Sliver App Bar + Custom Scrollview

Weekly Budget Flutter App A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get yo

Oct 21, 2021

A powerful extended official text for Flutter, which supports Speical Text(Image,@somebody), Custom Background, Custom overFlow, Text Selection.

A powerful extended official text for Flutter, which supports Speical Text(Image,@somebody), Custom Background, Custom overFlow, Text Selection.

Extended official text to build special text like inline image or @somebody quickly,it also support custom background,custom over flow and custom selection toolbar and handles.

Jan 4, 2023

Custom Gesture Detector for Flutter. Empower your users with custom gestures.

Gestures Custom Gesture Detector for Flutter. Empower your users with custom gestures. How to use In your pubspec.yaml: dependencies: gestures: ^1.0

Nov 4, 2022

A customizable carousel slider widget in Flutter which supports inifinte scrolling, auto scrolling, custom child widget, custom animations and built-in indicators.

A customizable carousel slider widget in Flutter which supports inifinte scrolling, auto scrolling, custom child widget, custom animations and built-in indicators.

flutter_carousel_widget A customizable carousel slider widget in Flutter. Features Infinite Scroll Custom Child Widget Auto Play Horizontal and Vertic

Nov 26, 2022

Flutter package that provides you custom clippers to help you achieve various custom shapes.

Flutter package that provides you custom clippers to help you achieve various custom shapes.

flutter_custom_clippers Flutter package that provides you custom clippers to help you achieve various custom shapes. Usage To use this plugin, add flu

Dec 23, 2022

Displays a scrollable timeline with custom child widgets and custom icons.

Displays a scrollable timeline with custom child widgets and custom icons.

Flutter Timeline Widget Displays a scrollable timeline with custom child widgets and custom icons. Installation In your pubspec.yaml file within your

Nov 20, 2022

FT-Custom-Widget - A Custom Widget Built With Flutter

FT-Custom-Widget - A Custom Widget Built With Flutter

Custom Widget Watch it on YouTube Product Screen Sample when you implement compl

Mar 29, 2022

Custom-Position-Popup - Custom Position Popup For Flutter

Custom-Position-Popup - Custom Position Popup For Flutter

Custom-Position-Popup before clone the GitHub repository please give a star on t

Oct 17, 2022

A customizable carousel slider for Flutter. Supports infinite sliding, custom indicators, and custom animations with many pre-built indicators and animations.

A customizable carousel slider for Flutter. Supports infinite sliding, custom indicators, and custom animations with many pre-built indicators and animations.

Flutter Carousel Slider A customizable carousel slider for flutter Screenshots Installing dependencies: flutter_carousel_slider: ^1.0.8 Demo Demo a

Nov 6, 2022

Custom map markers - Custom Map Markers Using Flutter

Custom map markers - Custom Map Markers Using Flutter

Custom Map Markers Not only "Everything is a widget" also "Everywhere is a widge

Oct 19, 2022

Flutter custom carousel slider - A carousel slider widget,support custom decoration suitable for news and blog

Flutter custom carousel slider - A carousel slider widget,support custom decoration suitable for news and blog

flutter_custom_carousel_slider A carousel slider Flutter widget, supports custom

Dec 29, 2022

Custom widget for Flutter

Custom widget for Flutter

Flushbar Use this package if you need more customization when notifying your user. For Android developers, it is made to substitute toasts and snackba

Dec 30, 2022

🔁 A custom refresh indicator for flutter.

🔁 A custom refresh indicator for flutter.

Liquid Pull To Refresh A beautiful and custom refresh indicator for flutter highly inspired from Ramotion Pull Down to Refresh. Table of contents Inst

Jan 8, 2023
Comments
  • Menu not resizing verticaly

    Menu not resizing verticaly

    Hi,

    your menu is great however:

    1. is menu is horizontal it does not resize vertically
    2. if menu is vertical it does not resize horizontaly

    this is a problem if i want to make icons larger for older people lets say i cannot do this.

    image

    Can you make hight also configurable or even better resize according to content height?

    opened by vytautas-pranskunas- 1
  • Menu above modal window

    Menu above modal window

    Hi, while it is good to have menu above all widgets but modal, i think, either should be an exception or maybe there is a programatic way to close menu?

    image

    opened by vytautas-pranskunas- 0
  • Background color of MenuItem not working

    Background color of MenuItem not working

    Delete icon suppose to have red background and white icon but... here is a code

    menuBar: MenuBar(
                                            backgroundColor: CustomColors.veryLightGrey,
                                            drawArrow: true,
                                            itemPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 4),
                                            menuItems: [
                                              MenuItem(child: Icon(Icons.chat, color: Colors.grey[600]), onTap: () => {}),
                                              MenuItem(child: Icon(Icons.done, color: Colors.grey[600])),
                                              MenuItem(
                                                  child: Icon(Icons.delete_forever, color: CustomColors.careWhite),
                                                  backgroundColor: CustomColors.imperialRed)
                                            ],
                                          ),
                                          child: IconButton(
                                            onPressed: null,
                                            icon: Icon(Icons.playlist_add, color: CustomColors.carePurple),
                                          ))
    

    image

    opened by vytautas-pranskunas- 0
Owner
Yan Min Hong
Code and cats. Flutter, apps, and a sprinkling of embedded goodness
Yan Min Hong
Custom Layout with interactive add button to impove your UI and UX .

Interactive Add button layout Custom Layout with interactive add button to impove your UI and UX . the package is available here inspired from Oleg Fr

Dokkar Rachid Reda 20 Sep 13, 2021
Create your own custom SlideTransition combined with some animation in Flutter.

Create your own custom SlideTransition combined with some animation in Flutter.

Johannes Milke 7 Jun 21, 2022
Writing custom Widgets in Flutter

Flutter - Custom Widgets Part 1 - EllipsizedText / LeafRenderObjectWidget Writing custom Widgets in Flutter (Part 1) — EllipsizedText Part 2 - ChildSi

Rostyslav Lesovyi 23 Dec 9, 2022
A flutter project with Implementation of a Contacts app in 4 ways (API, Custom, Preferences and Sqflite).

Contacts A flutter project with Implementation of a Contacts app in 4 ways (API, Custom, Preferences and Sqflite). It consist some common operations l

Harsh Sharma 118 Nov 20, 2022
Clip your widgets with custom shapes provided.

clippy_flutter Clip your widgets with custom shapes provided. #Arc, #Arrow, #Bevel, #ButtCheek, #Chevron, #Diagonal, #Label, #Message, #Paralellogram,

Figen Güngör 238 Dec 11, 2022
🎨Custom animation challenge annouced by egdroid

EgdroidChallenge Follow me on social media github linkedin twitter facebook ?? challenge accepted ?? A challenge code series idea suggested by an awes

null 16 Aug 28, 2020
A custom Flutter value slider that makes a wave effect when dragged.

A Flutter slider that makes a wave effect when dragged. Does a little bounce when dropped. Demo Getting Started To use this plugin, add wave_slider as

Gordon Hayes 33 Dec 21, 2022
Loading widget based on a Flare animation, allow you to create beautiful custom loading widgets or dialogs

flare_loading Loading widget based on a Flare animation, allow you to create custom loading widgets or dialogs If you're using Rive instead of Flare p

Jimmy Aumard 25 Apr 16, 2021
A Flutter package to custom splash screen like change logo icon, logo animation, and splash screen background color.

Custom Splash Screen A Flutter package to custom splash screen: change logo icon, logo animation, and splash screen background color. (Custom from ani

tranhuycong 78 Sep 6, 2022
A simple custom loading indicator package.

custom_loading_indicator A Flutter package to customise the loading indicators with your organisation's logo. Let's say you're a dentist and your app

Harshad Manglani 3 Aug 10, 2020