I want to use snack bar in a widget but the scaffold is in a different widget. I have used ScaffoldMessenger but not showing and no errors.[ScaffoldMessenger used in a widget that is two widget inside of parent widget which has a scaffold]
CodePudding user response:
If you pass the BuildContext
(of the different widget which holds the Scaffold
) into the widget from where you'd like to show the Snackbar
, you should be able to use ScaffoldMessenger.of(passedContext).showSnackBar()
If this doesn't answer your question. Please provide a minimal code snippet of what you've tried.
CodePudding user response:
also, you can show SnackBar using GET,
you have to add get in your pubspec.yml in dependencies section
code : Get.snackbar("Hi..", "How are you !");