showNotification function
This method can be used by the client to show a Notification as an overlay
Implementation
Future<NotificationWidgetState> showNotification(
{String? title,
required String message,
TextStyle? messageStyle,
TextStyle? titleStyle,
Color? backgroundColor,
int? notificationDuration,
int? animDuration,
bool? autoDismissible}) async {
/// Throws an error if message is null
assert(message != null, '''Notification message cannot be null''');
try {
final instance = NotificationWidget(
disposeOverlay: hideNotification,
backgroundColor: backgroundColor,
message: message,
title: title,
messageStyle: messageStyle,
titleStyle: titleStyle,
autoDismissible: autoDismissible,
duration: notificationDuration,
animDuration: animDuration,
);
final child = Positioned(
left: 8.0,
right: 8.0,
child: instance,
);
_printLog('''Showing Notification overlay''');
await _showOverlay(child: child, type: _OverlayType.Notification);
return instance.get();
} catch (err) {
_printError('''Caught an exception while trying to show Notification''');
throw err;
}
}