showResultDialog<T> function Null safety

Future<T?> showResultDialog<T>(
  1. BuildContext context,
  2. {Key? key,
  3. required Color backgroundColor,
  4. required Color textColor,
  5. required Widget icon,
  6. Widget? title,
  7. Widget? content,
  8. DialogAction<T>? action,
  9. bool barrierDismissible = false,
  10. Color? barrierColor,
  11. bool useSafeArea = true,
  12. bool useRootNavigator = true,
  13. RouteSettings? routeSettings}
)

Generic method used to generate the dialogs of success, warning and error.

Use this method if you want to create a similar dialog with other colors and icons.

Implementation

Future<T?> showResultDialog<T>(BuildContext context,
    {Key? key,
    required Color backgroundColor,
    required Color textColor,
    required Widget icon,
    Widget? title,
    Widget? content,
    DialogAction<T>? action,
    bool barrierDismissible = false,
    Color? barrierColor,
    bool useSafeArea = true,
    bool useRootNavigator = true,
    RouteSettings? routeSettings}) async {
  return showDialog<T>(
      context: context,
      builder: (context) {
        return WillPopScope(
            onWillPop: () => Future.value(barrierDismissible),
            child: ResultDialog(
                key: key,
                backgroundColor: backgroundColor,
                textColor: textColor,
                icon: icon,
                title: title,
                content: content,
                action: (action ??
                    DialogAction<T>(
                        title: Text(StandardDialogsLocalizations.of(
                            context)[DialogResult.ok])))));
      },
      barrierDismissible: barrierDismissible,
      barrierColor: barrierColor,
      useSafeArea: useSafeArea,
      useRootNavigator: useRootNavigator,
      routeSettings: routeSettings);
}