showWebViewDialog static method

Future<WidgetResult?> showWebViewDialog(
  1. BuildContext context,
  2. String? title,
  3. String initialUrl,
  4. String? jsToInject,
  5. DialogStyles? styles,
)

Implementation

static Future<WidgetResult?> showWebViewDialog(BuildContext context, String? title, String initialUrl, String? jsToInject, DialogStyles? styles) {
  return showModalBottomSheet<WidgetResult>(
    context: context,
    isScrollControlled: true,
    isDismissible: false,
    enableDrag: false,
    backgroundColor: Colors.white,
    barrierColor: Colors.black.withOpacity(0.5),
    shape: const RoundedRectangleBorder(
      borderRadius: BorderRadius.only(
        topLeft: Radius.circular(16),
        topRight: Radius.circular(16),
      ),
    ),
    builder: (BuildContext sheetContext) {
      return SizedBox(
        height: MediaQuery.of(context).size.height * (styles?.height ?? 0.92),
        child: Column(
          children: [
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 4),
              child: Row(
                children: [
                  const SizedBox(width: 48),
                  Expanded(
                    child: title != null
                        ? Text(
                            title,
                            textAlign: TextAlign.center,
                            style: const TextStyle(
                              color: Colors.black,
                              fontSize: 18,
                              fontWeight: FontWeight.w600,
                            ),
                          )
                        : const SizedBox.shrink(),
                  ),
                  IconButton(
                    icon: const Icon(Icons.close, color: Colors.black),
                    onPressed: () {
                      final webViewState = _webViewKey.currentState;
                      final result = webViewState?.lastResult;
                      Navigator.of(sheetContext).pop(WidgetResult.success(result));
                    },
                  ),
                ],
              ),
            ),
            Expanded(
              child: BasicWebViewWidget(key: _webViewKey, initialUrl: initialUrl, jsToInject: jsToInject),
            ),
          ],
        ),
      );
    },
  );
}