openBugReport function

Future<void> openBugReport(
  1. dynamic context, {
  2. Map<String, String>? queryParams,
})

Implementation

Future<void> openBugReport(
  BuildContext context, {
  Map<String, String>? queryParams,
}) async {
  if (_bugReportOpen) {
    return;
  }
  queryParams = queryParams ?? {};
  final cacheDir = await appCacheDir();
  // rage shake disallows dot in filename
  final timestamp = DateTime.now().timestamp;
  final imagePath = await screenshotController.captureAndSave(
    cacheDir,
    fileName: 'screenshot_$timestamp.png',
  );
  if (imagePath != null) {
    queryParams['screenshot'] = imagePath;
  }
  if (!context.mounted) {
    _log.warning('Trying to open the bugreport without being mounted');
    return;
  }
  _bugReportOpen = true;
  await context.pushNamed(
    Routes.bugReport.name,
    queryParameters: queryParams,
  );
  _bugReportOpen = false;
}