showSnackbar function
void
showSnackbar(
- String text, {
- int? seconds,
- required BuildContext context,
- bool debugMode = false,
- bool storeLogs = false,
Shows a SnackBar at the bottom of the screen.
text is the message to be displayed.
seconds is the duration for which the SnackBar is visible. Defaults to 2 seconds.
context is the BuildContext from which to find the ScaffoldMessenger.
debugMode if true, the SnackBar will only be shown in debug builds (kDebugMode).
The SnackBar is always shown if debugMode is false.
storeLogs is a flag that was intended to store logs of SnackBar messages,
but the implementation is currently commented out.
Implementation
void showSnackbar(
String text, {
int? seconds,
required BuildContext context,
bool debugMode = false,
bool storeLogs = false,
}) {
if (debugMode == false || kDebugMode == false) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(text),
duration: Duration(seconds: seconds ?? 2),
// margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
// behavior: SnackBarBehavior.floating,
),
);
}
// if(storeLogs==true ){
//
// Map<String,dynamic> request = {
// 'time': Timestamp.now(),
// 'message': text
// };
//
// if(userData!=null){
// FirebaseCollections.users.doc(userData?.userId).collection("snackbarlogs").add(request);
// }
// roughPageLogs.add('${DateTime.now()} $text');
//
// }
}