FloatingActionButton onLongPress listener in Flutter

I'd suggest to use InkWell so that you can also have ripple effect.

Here is how you can use it.

floatingActionButton: InkWell(
  splashColor: Colors.blue,
  onLongPress: () {
    // handle your long press functionality here
  },
  child: FloatingActionButton(
    child: Icon(Icons.add),
    onPressed: someFunction,
  ),
)

You can create your own LongPressFloatingActionButton, because the StatefullWidget already has this option.

See at: Flutter - I want to select the card by onLongPress?

Api: https://api.flutter.dev/flutter/flutter_test/WidgetController/longPress.html

Inside the state of your new CustomStatefullWidget that wraps the FloatingActionButton you use it like:

class CustomWidget extends StatefulWidget {
  final int index;
  final bool longPressEnabled;
  final VoidCallback callback;

  const CustomWidget({Key key, this.index, this.longPressEnabled, this.callback}) : super(key: key);

  @override
  _CustomWidgetState createState() => new _CustomWidgetState();
}

class _CustomWidgetState extends State<CustomWidget> {
  bool selected = false;

  @override
  Widget build(BuildContext context) {
    return new GestureDetector(
      onLongPress: () {
        setState(() {
          selected = !selected;
        });
        widget.callback();
      },