0

How do I display a snackbar after a delay in Flutter? I tried

Future.delayed(const Duration(milliseconds: 5000), () { ... }

but it doesn't delay it at all.

MSpeed
  • 8,153
  • 7
  • 49
  • 61

1 Answers1

3

Well you have to do this after your future execution ends. You do this with then future method.

Future.delayed(Duration(seconds: 5)).then((_) {
         // this code is executed after the future ends.
        _scaffoldKey.currentState.showSnackBar( SnackBar(content: Text("SNACKBAR") ) );
} );
Marcos Boaventura
  • 4,641
  • 1
  • 20
  • 27