Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FloatingActionButton onLongPress listener in Flutter

I need to have a secondary action to be performed during the long press of my FloatingActionButton in my app.

floatingActionButton: FloatingActionButton(
  onPressed: someFunction,
  child: Icon(Icons.add),
  onLongPressed: //Something like this or any other solution
),
like image 467
MubarakZade Avatar asked Aug 27 '19 19:08

MubarakZade


Video Answer


1 Answers

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,
  ),
)
like image 130
CopsOnRoad Avatar answered Oct 25 '22 23:10

CopsOnRoad