0
_scaffoldKey.currentState.showSnackBar(SnackBar(
      content: Text('You dont have enough money'),
    ));

When I give it time it does not work as well. Can it be because I am calling it from a function?

aebal99
  • 43
  • 5

1 Answers1

0

SnackBar has a property duration , use to duration property to set time till you want to show sSnackBar after tha it will disappear automatically.

   _scaffoldKey.currentState.showSnackBar(SnackBar(
    content: Text('You dont have enough money'),
    duration: Duration(seconds: 2),
   ));
Amit Kumar
  • 197
  • 1
  • 6