alert static method

Future<bool?> alert(
  1. String title, {
  2. List<TextSpan> description = const [],
  3. List<Widget> additional = const [],
  4. Widget button(
    1. BuildContext
    ) = _defaultButton,
})

Shows a confirmation popup with the specified title, description, and additional widgets to put under the description.

Implementation

static Future<bool?> alert(
  String title, {
  List<TextSpan> description = const [],
  List<Widget> additional = const [],
  Widget Function(BuildContext) button = _defaultButton,
}) {
  final style = Theme.of(router.context!).style;

  return ModalPopup.show(
    context: router.context!,
    child: Builder(
      builder: (context) {
        return Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            const SizedBox(height: 4),
            ModalPopupHeader(text: title),
            const SizedBox(height: 13),
            Flexible(
              child: ListView(
                shrinkWrap: true,
                children: [
                  if (description.isNotEmpty)
                    Padding(
                      padding: ModalPopup.padding(context),
                      child: Center(
                        child: RichText(
                          text: TextSpan(
                            children: description,
                            style: style.fonts.normal.regular.secondary,
                          ),
                        ),
                      ),
                    ),
                  ...additional.map(
                    (e) => Padding(
                      padding: ModalPopup.padding(context),
                      child: e,
                    ),
                  ),
                ],
              ),
            ),
            const SizedBox(height: 25),
            Padding(
              padding: ModalPopup.padding(context),
              child: button(context),
            ),
            const SizedBox(height: 16),
          ],
        );
      },
    ),
  );
}