'Show Snackbar Reactively Using GetX in Flutter
This is the scenario
- Making an API call
- Response is empty
- Need to show 'No results found' msg to the user through Snackbar from GetX controller
- But I don't want to pass the instance of the view class to the controller to show the Snackbar.
- Is there any Getx widget that listens to the msg.obs value in the controller and executes Get.Snackbar() code in the view
Solution 1:[1]
You can use below code for show snackbar in flutter
Get.snackbar(
"Hello",
"Thank You!",
snackPosition: SnackPosition.TOP,
colorText: Colors.white,
borderRadius: 10,
backgroundColor: AppColors.toastGreenColor ,
icon: Image.asset(
"assets/images/success_toast.png",
height: 25,
width: 25,
color: Colors.white,
),
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ravi Limbani |
