23 lines
808 B
Dart
23 lines
808 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: 8.0, // Inner padding for SnackBar content.
|
|
),
|
|
content: Text(
|
|
text,
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(color: textColor),
|
|
)
|
|
);
|
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
|
}
|