A Flutter package to create a nice circular menu using a Floating Action Button.

Overview

FAB Circular Menu

Pub Pull Requests are welcome Codemagic build status Null safety

A Flutter package to create a nice circular menu using a Floating Action Button.

Inspired by Mayur Kshirsagar's great FAB Microinteraction design.

Showcase

Installation

Just add fab_circular_menu to your pubspec.yml file

dependencies:
  fab_circular_menu: ^1.0.0

Example

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Placeholder(),
        floatingActionButton: FabCircularMenu(
          children: <Widget>[
            IconButton(icon: Icon(Icons.home), onPressed: () {
              print('Home');
            }),
            IconButton(icon: Icon(Icons.favorite), onPressed: () {
              print('Favorite');
            })
          ]
        )
      )
    );
  }
}

You can check for a more complete example in the example directory.

Customize

You can customize the widget appareance using the following properties:

Property Description Default
alignment Sets the widget alignment Alignment.bottomRight
ringColor Sets the ring color accentColor
ringDiameter Sets the ring diameter screenWidth * 1.25 (portrait)
screenHeight * 1.25 (landscape)
ringWidth Sets the ring width ringDiameter * 0.3
fabSize Sets the FAB size 64.0
fabElevation Sets the elevation for the FAB 8.0
fabColor Sets the FAB color primaryColor
fabOpenColor Sets the FAB color while the menu is open. This property takes precedence over fabColor -
fabCloseColor Sets the FAB color while the menu is closed. This property takes precedence over fabColor -
fabChild Sets the child inside the FAB. This property takes precedence over fabOpenicon and fabCloseIcon -
fabOpenIcon Sets the FAB icon while the menu is open Icon(Icons.menu)
fabCloseIcon Sets the FAB icon while the menu is closed Icon(Icons.close)
fabMargin Sets the widget margin EdgeInsets.all(16.0)
animationDuration Changes the animation duration Duration(milliseconds: 800)
animationCurve Allows you to modify the animation curve Curves.easeInOutCirc
onDisplayChange This callback is called every time the menu is opened or closed, passing the current state as a parameter. -

Handling the menu programmatically

It is possible to handle the menu programatically by using a key. Just create a key and set it in the key property of the FabCircularMenu, then use the key to get the current state and open, close or check the status of the menu.

class MyApp extends StatelessWidget {
  final GlobalKey<FabCircularMenuState> fabKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: RaisedButton(
          onPressed: () {
            if (fabKey.currentState.isOpen) {
              fabKey.currentState.close();
            } else {
              fabKey.currentState.open();
            }
          },
          child: Text('Toggle menu')
        ),
        floatingActionButton: FabCircularMenu(
          key: fabKey,
          children: <Widget>[
            // ...
          ]
        )
      )
    );
  }
}

Contributing

I will be very happy if you contribute to this project, please submit a PR 😁

Comments
  • Menu not auto close after clicked on menu item

    Menu not auto close after clicked on menu item

    After clicked on one menu item, I want a solution to close menu by code but I can't found anyway to do it at the moment. This feature is quite comment, I think it should be an item in wishlist features :) Thanks for your time.

    enhancement 
    opened by chungbkhn 5
  • some probs

    some probs

    1. why do you force the child parameter? seems it is not really necessary.
    2. I suggest to assert required params, e.g. FabCircularMenu(...) : assert(child != null), assert(options != null && options.length > 0);
    3. If you want to provide this code as a library you need to move it to the lib/src folder and provide a dart file with export statements. See other libs. Currently I am unable to use your code as a lib. I rather copied the source code into my own repository instead.
    4. Please add a dispose method:
        @override
        void dispose() {
          controller?.dispose();
          super.dispose();
        }
    
    1. I still struggle when using 4 icons. In closed state the middle icons 1 and 2 are shown in the right-bottom corner beneath the fab.

    grafik

    grafik

    You may find the problem, I don't currently.

    1. Seems it is not allowed to init the controller twice. Move that initialization to the initState() method instead:
      @override
      void initState() {
        super.initState();
        controller = AnimationController(duration: widget.animationDuration, vsync: this);
      }
    
    opened by mikes222 4
  • Added fabChild property to specify custom fab child

    Added fabChild property to specify custom fab child

    Hey Mariano, I recently used your fab circular menu and I wanted to use a custom flare animation as a child of the fab so I just modified the code to add this possibility!

    opened by PepeExpress 3
  • Add onClicked/onOpen attribute for floating action button

    Add onClicked/onOpen attribute for floating action button

    Currently I would like my other buttons to close when I click on the FABcircularMenu, but the widget lacks an attribute for me to have a callback, I cant do so :(

    enhancement 
    opened by jadenwjh 2
  • More of a Question than an issue - how to add text below the icon?

    More of a Question than an issue - how to add text below the icon?

    I tried to create a Column widget with the Icon and the Text widget, but then the button would be placed in a random place far away from where it was supposed to. I even tried the column as a child of the RawMaterialButton, but same result.

    Is it possible to add text below the icon with this package? I would love know. Great package thanks for the content!

    opened by pedez 2
  • Need ringWidth, please Advise?

    Need ringWidth, please Advise?

    Hi, I am trying out my project on Web too. Thats where I need the ringWidth. I see you get this from ringDiameter.. and that from screenWidth.

    Is there any recommended way that I may get that present ringWidth? Besides doing the entire thing from scratch with Screen class?? Also, if there isnt, how may I know when the widget has finished its constructor, because thats the time I might try to trap the fabKey.currentState.widget.ringDiameter value into a double variable.

    thanks, Great package by the way!

    enhancement 
    opened by YohanWadia 2
  • [Request] I wanna be change fab close button background color.

    [Request] I wanna be change fab close button background color.

    Hello.

    I wanna be change fab close button background color. I do not find interface to change background color. Can you add "fabCloseColor" property ?

    Best regards.

    opened by hukusuke1007 2
  • where is FabCircularMenuController and how can i import that

    where is FabCircularMenuController and how can i import that

    could yuu help me how can i do that?

    Hey! First of all, thanks for waiting. I've just added a controller property that takes a FabCircularMenuController which allows you to control the menu programatically.

    final controller = FabCircularMenuController();
    
    FabCircularMenu(
      child: ...,
      controller: controller,
      options: <Widget>[
        IconButton(icon: Icon(Icons.widgets), onPressed: () {
          controller.isOpen = false;
        }, iconSize: 48.0, color: Colors.white),
        ...
      ],
     )
    

    I will improve documentation and examples soon.

    Originally posted by @marianocordoba in https://github.com/marianocordoba/fab-circular-menu/issues/4#issuecomment-596169323

    opened by pishguy 1
  • Support to Null Safety

    Support to Null Safety

    opened by deandreamatias 1
  • Exception when use controller to close

    Exception when use controller to close

    Hi. when use it inside tab view, after change of tab, I have this exception:

    Basically in this case we need use animation after dispose, any idea?

    AnimationController.reverse() called after AnimationController.dispose()
    AnimationController methods should not be used after calling dispose.
    'package:flutter/src/animation/animation_controller.dart':
    Failed assertion: line 488 pos 7: '_ticker != null'
    
    opened by j574144 1
  • opTap is not working on children

    opTap is not working on children

    I just wrap children in GestureDetector so I can do something onTap. but it's not working.

    options: <Widget>[
                  GestureDetector(
                    behavior: prefix0.HitTestBehavior.opaque,
                    onTap: () => print('1'),
                    child: IconButton(
                      icon: Icon(Icons.widgets),
                      onPressed: () {},
                      iconSize: 48.0,
                      color: Colors.red,
                    ),
                  ),
                  GestureDetector(
                    onTap: () => print('2'),
                    child: IconButton(
                      icon: Icon(Icons.widgets),
                      onPressed: () {},
                      iconSize: 48.0,
                      color: Colors.white,
                    ),
                  ),
                  GestureDetector(
                    onTap: () => print('3'),
                    child: IconButton(
                      icon: Icon(Icons.widgets),
                      onPressed: () {},
                      iconSize: 48.0,
                      color: Colors.white,
                    ),
                  )
                ],
    
    opened by samad324 1
  • Fixes #14 and #26 and #38

    Fixes #14 and #26 and #38

    Regarding #14: swapping the OverflowBox and the Translation + scale transformation seems to help. Regarding #26: we just need to multiply the margin values by -1 or 1 based on where the menu is. Those factors are already available in the _directionX and _directionY variables. Regarding #38: using WidgetsBindingObserver's didChangeMetrics callback we call _calculateProps() and also close() if the menu is open.

    opened by MrCsabaToth 8
  • Margins are not calculated properly unless the menu is in the default bottom right location

    Margins are not calculated properly unless the menu is in the default bottom right location

    This is because the main Container's transform: Matrix4.translationValues(16.0, 16.0, 0.0) does not take into account the alignment and always does the translation into one direction both axis. It should be transform: Matrix4.translationValues(16.0 * _directionX, 16.0 * _directionY, 0.0) instead. I'll push a fix.

    opened by MrCsabaToth 0
  • Adding an attribute to skip the margin offset for the fab

    Adding an attribute to skip the margin offset for the fab

    In my case, I was positioning the FAB using a stack (I'm using ios scaffold widgets).

    The margin offsets were causing my button to float slightly to the left and downward. This attribute allows for removing the margin offset transformation.

    opened by ericmartineau 2
Floating Action Button Widget For Flutter

Flutter Tutorial - FloatingActionButton Widget (FAB) Embed the FloatingActionBut

Behruz Hurramov 0 Dec 27, 2021
Master Channel cannot use Glass Floating Action Button

Problem Master Channel cannot use GlassFloatingActionButton. About This package

null 7 Oct 2, 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
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
A customizable Flutter library that provides a circular context menu

Flutter Pie Menu ?? A customizable Flutter library that provides a circular context menu similar to Pinterest's. Usage Wrap the widget that will react

Raşit Ayaz 14 Jan 4, 2023
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

Daniel B Schneider 0 Dec 22, 2021
Swipeable button view - Create Ripple Animated Pages With Swipeable Button View

swipeable_button_view You can create ripple animated pages with swipeable_button

cemreonur 3 Apr 22, 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
Show a draggable floating chat icon button and show messages on screens

Show a draggable floating chat icon button and show messages on screens Features A widget for displaying a chat icon (or custom widget) on top of a ba

CU Apps 4 May 5, 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
Flutter plugin to display a popup menu button widget with handsome design and easy to use.

menu_button Flutter widget to display a popup menu button very simply and easily customizable. Resources Documentation Pub Package GitHub Repository I

Hugo EXTRAT 63 Sep 27, 2022
Iosish indicator - 🍎 Create awesome and simple iOS style floating indicator which can be found when silent/sleep mode switched on Flutter.

Iosish indicator - ?? Create awesome and simple iOS style floating indicator which can be found when silent/sleep mode switched on Flutter.

Kim Seung Hwan 2 Apr 1, 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
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

null 6 Dec 23, 2022
GitHub Action that uses the Dart Package Analyzer to compute the Pub score of Dart/Flutter packages

Dart/Flutter package analyzer This action uses the pana (Package ANAlysis) package to compute the score that your Dart or Flutter package will have on

Axel Ogereau-Peltier 45 Dec 29, 2022
Flutter package to create list of radio button, by providing a list of objects it can be a String list or list of Map.

Custom Radio Group List Flutter package to create list of radio button, by providing a list of objects it can be a String list or list of Map. Feature

Ashok Kumar Verma 0 Nov 30, 2021
A Flutter package providing an easy way to add floating ribbon to images.

Floating Ribbon A new Flutter package for creating floating ribbons on images. Dependency dependencies: floating_ribbon: any How To Use In order to

101Loop 12 Sep 26, 2022
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
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