error static method

Future<void> error({
  1. required BuildContext context,
  2. String? title,
  3. bool shouldOpenNewIssue = false,
})

Shows an loading error dialog.

Typical use-case: when the run call failed.

Implementation

static Future<void> error({
  required BuildContext context,
  String? title,
  bool shouldOpenNewIssue = false,
}) async => showDialog<void>(
  context: context,
  builder: (BuildContext context) {
    final AppLocalizations appLocalizations = AppLocalizations.of(context);
    return SmoothAlertDialog(
      body: Column(
        children: <Widget>[
          SvgPicture.asset(
            'assets/misc/error.svg',
            width: MINIMUM_TOUCH_SIZE * 2,
            package: AppHelper.APP_PACKAGE,
          ),
          Padding(
            padding: const EdgeInsets.symmetric(vertical: MEDIUM_SPACE),
            child: Text(
              shouldOpenNewIssue
                  ? appLocalizations.server_error_open_new_issue
                  : title ??
                        appLocalizations.loading_dialog_default_error_message,
              textAlign: TextAlign.center,
            ),
          ),
          if (shouldOpenNewIssue)
            Padding(
              padding: const EdgeInsets.only(bottom: MEDIUM_SPACE),
              child: RichText(
                textAlign: TextAlign.center,
                text: TextSpan(
                  style: Theme.of(
                    context,
                  ).textTheme.bodyMedium?.copyWith(color: Colors.blue),
                  text: Status.openNewIssueUrl,
                  recognizer: TapGestureRecognizer()
                    ..onTap = () =>
                        LaunchUrlHelper.launchURL(Status.openNewIssueUrl),
                ),
              ),
            ),
        ],
      ),
      positiveAction: SmoothActionButton(
        text: appLocalizations.close,
        onPressed: () => Navigator.maybePop(context),
      ),
    );
  },
);