final snackBar = SnackBar(content: Text('Yay! A SnackBar!')); // Find the ScaffoldMessenger in the widget tree // and use it to show a SnackBar. ScaffoldMessenger.of(context).showSnackBar(snackBar);