'Flutter slidable package can be closed programatically?

As I've seen in the Slidable package documentation you should, at least in theory, close the ActionPane with the Slidable.of(context).close() function but it returns the following error:

My code:

 onTap: () {
              Slidable.of(context).close();
            },

My error:

The method 'close' was called on null.
Receiver: null
Tried calling: close()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source