A customizable Flutter library that provides a circular context menu

Overview

Flutter Pie Menu 🥧

A customizable Flutter library that provides a circular context menu similar to Pinterest's.

Usage

Wrap the widget that will react to gestures with PieMenu widget, and give the menu a list of PieActions to display as menu buttons.

PieMenu(
  actions [
    PieAction(
      tooltip: 'Like',
      iconData: Icons.favorite,
      onSelect: () => print('Like action selected.'),
    ),
  ],
  child: YourWidget(),
),

Note that you can only use PieMenu in the sub-hierarchy of a PieCanvas widget. Wrap the parent widget of your page (or any other widget you want to draw the canvas on) with PieCanvas widget.

For example, if you want the menu to be displayed at the forefront, you can wrap your Scaffold with a PieCanvas like following:

PieCanvas(
  child: Scaffold(
    body: YourScaffoldBody(
      ...
        PieMenu(),
      ...
    ),
  ),
),

Using with Scrollable and Interactive Widgets

⚠️ If you want to use PieMenu inside a scrollable view like a ListView, or your widget is already interactive (e.g. it is clickable), you may need to pay attention to this section.

PieCanvas has a functional callback named onMenuToggle which is triggered when a PieMenu that inherits the respective canvas is opened and closed. Using this callback, you can prevent your scrollable or interactive widget's default behavior in order to give the control to the PieMenu.

If you can think of a better implementation to handle this automatically, feel free to create a new issue on this package's repository and express your opinion.

Using the menuVisible parameter of the onMenuToggle callback, store a bool variable in your StatefulWidget state.

bool _menuVisible = false;

@override
Widget build(BuildContext context) {
  return PieCanvas(
    onMenuToggle: (menuVisible) {
      setState(() => _menuVisible = menuVisible);
    },
    ...
  );
}

Scrollable Widgets

Using the _menuVisible variable, you can decide whether scrolling should be enabled or not.

ListView(
  // Disable scrolling if a 'PieMenu' is visible
  physics: _menuVisible
      ? NeverScrollableScrollPhysics()
      : ScrollPhysics(), // Or your own scroll physics
  ...
);

Interactive Widgets

Again using the _menuVisible variable, you can disable the default behavior of your interactive widget. For example, if your widget detects taps using a GestureDetector, you can nullify the onTap callback when a PieMenu is visible.

GestureDetector(
  onTap: _menuVisible
      ? null
      : () => print('Tap'),
),

Customization

You can customize the appearance and behavior of menus using PieTheme.

Using the theme attribute of PieCanvas widget, you can specify a theme for all the PieMenus that inherit it.

PieCanvas(
  theme: PieTheme(),
  ...
    PieMenu(), // Uses the canvas theme
  ...
    PieMenu(), // Uses the canvas theme
  ...
),

But if you want to specify menu specific themes, you can also use the theme attribute of PieMenu widget.

PieMenu(
  theme: PieTheme(), // Overrides the canvas theme
),

Buttons' background and icon colors are defined by theme's buttonTheme and hoveredButtonTheme properties. You can create a custom PieButtonTheme instances for your theme.

PieTheme(
  buttonTheme: PieButtonTheme(),

  // Using 'hovered' constructor is not necessary
  hoveredButtonTheme: PieButtonTheme.hovered(),
),

If you want to use a custom widget instead of an icon for the action button, you can use the customWidget and customHoveredWidget properties of the respective PieAction.

You might also like...

Open source Flutter package, simple circular progress bar.

Open source Flutter package, simple circular progress bar.

Simple circular progress bar Open source Flutter package, simple circular progress bar. Getting Started Installing Basic Examples Colors Start angle L

Dec 23, 2022

A simple button that gives you the possibility to transform into a circular one and shows a progress indicator

A simple button that gives you the possibility to transform into a circular one and shows a progress indicator

Progress Button A simple button that gives you the possibility to transform into

Dec 22, 2021

A Dart package that provides a customizable country phone code picker for your Flutter application

A Dart package that provides a customizable country phone code picker for your Flutter application

A Flutter package that provides an easy and customizable country phone code picker widget! Features This package comes with a lot of customization all

Oct 1, 2022

A package that provides a highly customizable sheet widget that snaps to different vertical & horizontal positions

A package that provides a highly customizable sheet widget that snaps to different vertical & horizontal positions

Snapping Sheet A package that provides a highly customizable sheet widget that snaps to different vertical & horizontal positions Can adapt to scrolla

Dec 6, 2022

Easy nav - A simple wrapper around flutter navigator, dialogs and snackbar to do those things without context

EasyNav Just a simple wrapper around flutter navigator, dialogs and snackbar to

Feb 26, 2022

Flutter project being built in the context of Smart India Hackathon { SIH }.

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

Dec 29, 2022

Flutter In-Context Editing example

Flutter In-Context Editing example

Flutter In-Context Editing example Instantly see how your translations fit on a real device without unnecessary app builds Setup Clone the repo Run fl

Jun 3, 2022

Build context - Access most used properties in your BuildContext instance.

Languages: English | Brazilian Portuguse BuildContext Access most used properties in your BuildContext instance. This package relies on Dart's extensi

Dec 11, 2022

Bringing back contex.read and context.watch for riverpod

This package brings back the context extensions for riverpod that were discontinued in version 1.0.0. To read any provider, do context.read(myProvider

Sep 28, 2022
Comments
  • How to disable child fade out when pressing menu widget

    How to disable child fade out when pressing menu widget

    I have the PieCanvas wrapping a whole page and at the PieMenu section for the child I wrap the actual menu button. However as soon as the button is pressed the whole wrapped menu disappears and only the radial PieActions become visible. How can I disable the disappearance of the wrapped elements or is there a way to make the PieActions float over the underlying elements?

    opened by xetra11 1
Releases(v1.2.6)
Owner
Raşit Ayaz
Raşit Ayaz
A Flutter package to create a nice circular menu using a Floating Action Button.

FAB Circular Menu A Flutter package to create a nice circular menu using a Floating Action Button. Inspired by Mayur Kshirsagar's great FAB Microinter

Mariano Cordoba 198 Jan 5, 2023
A customizable circular slider for Flutter.

flutter_circular_slider A customizable circular slider for Flutter. Getting Started Installation Basic Usage Constructor Use Cases Installation Add fl

David 193 Nov 14, 2022
This is a repository for Flutter Focused Menu, an easy to implement package for adding Focused Long Press Menu to Flutter Applications

Focused Menu This is an easy to implement package for adding Focused Long Press Menu to Flutter Applications Current Features Add Focused Menu to Any

Paras Jain 160 Dec 26, 2022
Arissettingsmenuexm - Settings Menu with different choices by clicking on a Popup Menu Button in Flutter

Flutter Tutorial - Settings Menu & AppBar Dropdown Menu Show a Flutter Settings

Behruz Hurramov 1 Jan 9, 2022
Flutter-pop-up-menu - Pop up Menu - Mobile Devices Programming

Pop Up Menu App A flutter demo app with a pop up menu button Developer Alexander Sosa (https://www.linkedin.com/in/alexander-sosa-asillanes/) Technolo

Alexander Sosa 0 Jan 3, 2022
This library provides a customizable Flutter widget that makes it easy to display text in the middle of a Divider.

1. About 1.1. Introduction 1.1.1. Install Library 1.1.2. Import It 1.1.3. Use TextDivider 1.2. Details 1.2.1. Customization Options 1.2.2. Horizontal

Kato Shinya 2 Feb 9, 2022
FlutterNavigator is a dart library for dealing with the Navigator API without a build context

FlutterNavigator is a dart library for dealing with the Navigator API without a build context. This package wraps the NavigatorKey and provides a cleaner service for navigating without context in your flutter application.

Luke Moody 10 Oct 1, 2022
A flutter UI package provides a cell widget that has leading and trailing swipe action menu.

Language: English |中文简体 flutter_swipe_action_cell A package that can give you a cell that can be swiped ,effect is like iOS native If you like this pa

WenJingRui 261 Jan 7, 2023
Flutter circular text widget

Circular Text Widget Installation Add dependency in pubspec.yaml: dependencies: flutter_circular_text: "^0.3.1" Import in your project: import 'pack

Farrukh 98 Dec 28, 2022
CircularProfileAvatar is a Flutter package which allows developers to implement circular profile avatar

CircularProfileAvatar is a Flutter package which allows developers to implement circular profile avatar with border, overlay, initialsText and many other awesome features, which simplifies developers job. It is an alternative to Flutter's CircleAvatar Widget.

Muhammad Adil 85 Oct 5, 2022