showCustomDialog<T, R> method
Future<DialogResponse<T> ?>
showCustomDialog<T, R>({
- dynamic variant,
- String? title,
- String? description,
- bool hasImage = false,
- String? imageUrl,
- bool showIconInMainButton = false,
- String? mainButtonTitle,
- bool showIconInSecondaryButton = false,
- String? secondaryButtonTitle,
- bool showIconInAdditionalButton = false,
- String? additionalButtonTitle,
- bool takesInput = false,
- Color barrierColor = Colors.black54,
- bool barrierDismissible = false,
- String barrierLabel = '',
- @Deprecated('Prefer to use `data` and pass in a generic type. customData doesn\'t work anymore') dynamic customData,
- R? data,
Creates a popup with the given widget, a scale animation, and faded background.
The first generic type argument will be the DialogResponse while the second generic type argument is the DialogRequest
e.g.
await _dialogService.showCustomDialog<GenericDialogResponse, GenericDialogRequest>();
Where GenericDialogResponse
is a defined model response,
and GenericDialogRequest
is the request model.
Implementation
Future<DialogResponse<T>?> showCustomDialog<T, R>({
dynamic variant,
String? title,
String? description,
bool hasImage = false,
String? imageUrl,
bool showIconInMainButton = false,
String? mainButtonTitle,
bool showIconInSecondaryButton = false,
String? secondaryButtonTitle,
bool showIconInAdditionalButton = false,
String? additionalButtonTitle,
bool takesInput = false,
Color barrierColor = Colors.black54,
bool barrierDismissible = false,
String barrierLabel = '',
@Deprecated('Prefer to use `data` and pass in a generic type. customData doesn\'t work anymore')
dynamic customData,
R? data,
}) {
assert(
_dialogBuilders != null,
'You have to call registerCustomDialogBuilder to use this function. Look at the custom dialog UI section in the stacked_services readme.',
);
final customDialogUI = _dialogBuilders![variant];
assert(
customDialogUI != null,
'You have to call registerCustomDialogBuilder to use this function. Look at the custom dialog UI section in the stacked_services readme.',
);
return Get.generalDialog<DialogResponse<T>>(
barrierColor: barrierColor,
transitionDuration: const Duration(milliseconds: 200),
barrierDismissible: barrierDismissible,
barrierLabel: barrierLabel,
pageBuilder: (BuildContext buildContext, _, __) => SafeArea(
key: Key('dialog_view'),
child: Builder(
builder: (BuildContext context) => customDialogUI!(
context,
DialogRequest<R>(
title: title,
description: description,
hasImage: hasImage,
imageUrl: imageUrl,
showIconInMainButton: showIconInMainButton,
mainButtonTitle: mainButtonTitle,
showIconInSecondaryButton: showIconInSecondaryButton,
secondaryButtonTitle: secondaryButtonTitle,
showIconInAdditionalButton: showIconInAdditionalButton,
additionalButtonTitle: additionalButtonTitle,
takesInput: takesInput,
data: data,
variant: variant,
),
completeDialog,
),
),
),
);
}