showTopModalSheet<T> function

Future<bool> showTopModalSheet<T>(
  1. BuildContext? context,
  2. Widget widget, {
  3. bool barrierDismissible = true,
})

Implementation

Future<bool> showTopModalSheet<T>(
  BuildContext? context,
  Widget widget, {
  bool barrierDismissible = true,
}) async {
  if (!(context?.mounted ?? false)) {
    ZegoLoggerService.logInfo(
      'show dialog error, context is not mounted, '
      'context:$context, ',
      tag: 'uikit',
      subTag: 'dialogs',
    );

    return false;
  }

  bool result = false;

  try {
    result = await showGeneralDialog<bool>(
          context: context!,
          barrierDismissible: barrierDismissible,
          transitionDuration: const Duration(milliseconds: 250),
          barrierLabel: MaterialLocalizations.of(context).dialogLabel,
          barrierColor: Colors.black.withOpacity(0.5),
          pageBuilder: (context, _, __) => ZegoScreenUtilInit(
            designSize: const Size(750, 1334),
            minTextAdapt: true,
            splitScreenMode: true,
            builder: (context, child) {
              return SafeArea(
                  child: Column(
                children: [
                  SizedBox(height: 16.zH),
                  widget,
                ],
              ));
            },
          ),
          transitionBuilder: (context, animation, secondaryAnimation, child) {
            return SlideTransition(
              position:
                  CurvedAnimation(parent: animation, curve: Curves.easeOutCubic)
                      .drive(Tween<Offset>(
                          begin: const Offset(0, -1.0), end: Offset.zero)),
              child: child,
            );
          },
        ) ??
        false;
  } catch (e) {
    ZegoLoggerService.logError(
      'showTopModalSheet, $e, '
      'context:$context, ',
      tag: 'uikit',
      subTag: 'dialogs',
    );
  }

  return result;
}