Buscar pacotes, repositórios e categorias de apps

Detalhes do pacotev0.1.2

flutter_anywhere_menus

Menus em qualquer lugar! Agora crie menus flutuantes que se posicionam automaticamente pelo widget pai ou pela localização do toque/click.

Downloads em 30 dias
37
Curtidas
36
Pontos Pub
40

Instalar pacote

flutter pub add flutter_anywhere_menus

Visão geral do pacote

Orientação gerada a partir de informações públicas. Apenas para referência.

Flutter Anywhere Menus é um pacote leve que permite aos desenvolvedores criar menus flutuantes que se posicionam dinamicamente em relação a um widget pai ou à localização do toque/clicar do usuário. Ideal para ações sensíveis ao contexto, ele melhora a interatividade da interface ao garantir que os menus apareçam exatamente onde são necessários, sem posicionamento manual. O pacote suporta design responsivo e se integra perfeitamente em aplicativos Flutter existentes. É especialmente útil em interfaces móveis onde o espaço é limitado e a navegação intuitiva é essencial.

Casos de uso

  • Menus de ação contextual
  • menus pop-up flutuantes
  • Posicionamento de menu baseado em toque
  • Componentes de interface responsiva
  • Melhorias na navegação do aplicativo móvel

Principais recursos

  • Posicionamento automático com base no pai ou toque
  • Leve e fácil integração
  • Suporte a ajustes dinâmicos de layout
  • Nenhuma configuração complexa necessária
  • Compatibilidade sem problemas com o Flutter

Indicado para

  • Desenvolvedores de aplicativos móveis
  • Designers de UI/UX
  • Construtores de interface interativa
  • Aplicativos com ações contextuais frequentes
  • Desenvolvedores procurando soluções rápidas de menu

Considerações

  • Limitado a plataformas Flutter
  • Sem animações embutidas
  • Requer manipulação manual de callbacks de itens de menu
  • Não otimizado para itens de menu grandes
  • Depende da hierarquia correta de widget para posicionamento

README original

Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.

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

  • [x] 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.

Categorias

Repositório-fonte

Projetos que usam este pacote

Ainda não há dados.