manager-app/lib/Components/message_notification.dart

28 lines
918 B
Dart

import 'package:flutter/material.dart';
showNotification (Color backgroundColor, Color textColor, String text, BuildContext context, int duration) {
final snackBar = SnackBar(
behavior: SnackBarBehavior.floating,
duration: duration == null ? Duration(milliseconds: 1500) : Duration(milliseconds: duration),
width: 280.0, // Width of the SnackBar.
backgroundColor: backgroundColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
padding: const EdgeInsets.symmetric(
horizontal: 10.0, // Inner padding for SnackBar content.
),
content: Container(
height: 32.5,
child: Center(
child: Text(
text,
textAlign: TextAlign.center,
style: TextStyle(color: textColor),
),
),
)
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}