fab_circular_menu_plus 0.0.4

SDKflutter
Platformandroidioswindowslinuxmacosweb

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

FAB Circular Menu

Pub package License Null safety Platform

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

Originally inspired by Mayur Kshirsagar's great FAB Microinteraction design. It is implemented as a Flutter plugin by Mariano Cordova (source code). This plugin is the continuation of the discontinued original plugin. I merged some of my bug fixes and made some changes to my liking.

I forked this plugin out of necessity and I have only a very limited time for maintenance, so PRs are highly welcome if any change is desired.

Showcase

Installation

Just add fab_circular_menu_plus to your pubspec.yml file

dependencies:
  fab_circular_menu_plus: ^0.0.1

Example

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Placeholder(),
        floatingActionButton: FabCircularMenuPlus(
          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 appearance using the following properties:

PropertyDescriptionDefault
alignmentSets the widget alignmentAlignment.bottomRight
ringColorSets the ring coloraccentColor
ringDiameterLimitFactorSets the ring diameter limit factor1.5
ringDiameterSets the ring diameterscreenWidth * ringDiameterLimitFactor (portrait)
screenHeight * ringDiameterLimitFactor (landscape)
ringWidthLimitFactorSets the ring width limit factor0.2
ringWidthSets the ring widthringDiameter * ringWidthLimitFactor
fabSizeSets the FAB size64.0
fabElevationSets the elevation for the FAB8.0
fabColorSets the FAB colorprimaryColor
fabOpenColorSets the FAB color while the menu is open. This property takes precedence over fabColor-
fabCloseColorSets the FAB color while the menu is closed. This property takes precedence over fabColor-
fabChildSets the child inside the FAB. This property takes precedence over fabOpenicon and fabCloseIcon-
fabOpenIconSets the FAB icon while the menu is openIcon(Icons.menu)
fabCloseIconSets the FAB icon while the menu is closedIcon(Icons.close)
fabMarginSets the widget marginEdgeInsets.all(16.0)
animationDurationChanges the animation durationDuration(milliseconds: 800)
animationCurveAllows you to modify the animation curveCurves.easeInOutCirc
onDisplayChangeThis 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 programmatically by using a key. Just create a key and set it in the key property of the FabCircularMenuPlus, 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<FabCircularMenuPlusState> 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: FabCircularMenuPlus(
          key: fabKey,
          children: <Widget>[
            // ...
          ]
        )
      )
    );
  }
}

Contributing

I will be very happy if you contribute to this project, feel free to submit a PR.