requestRecording method

Future<void> requestRecording(
  1. BuildContext context, {
  2. bool includeReplay = true,
  3. bool includePerformance = false,
  4. double frameBudgetMs = 16.67,
})

Implementation

Future<void> requestRecording(
  BuildContext context, {
  bool includeReplay = true,
  bool includePerformance = false,
  double frameBudgetMs = 16.67,
}) async {
  if (!frameBudgetMs.isFinite || frameBudgetMs <= 0) {
    throw ArgumentError.value(frameBudgetMs, "frameBudgetMs");
  }
  if (!_active || _recording || isPresentingUi) return;
  if (!isDeviceApproved) {
    await showDeviceRegistration();
    return;
  }
  _recordingPromptOpen = true;
  final promptGeneration = ++_generation;
  _notifyUi();
  try {
    final route = DialogRoute<bool>(
      context: context,
      settings: _ReporterRouteSettings(this),
      builder: (c) => AlertDialog(
        title: const Text('Start diagnostic recording'),
        content: Text(
          includeReplay
              ? 'Record up to 60 seconds of app screens and 120 seconds of diagnostic events locally on this device. Designated private areas are excluded. You can review the report and consent separately before sending. Do not include personal input or secrets in diagnostic logs.${includePerformance ? ' Flutter frame performance will also be recorded.' : ''}'
              : 'Record up to 120 seconds of diagnostic events locally on this device. No replay images are recorded. You can review the report and consent separately before sending. Do not include personal input or secrets in diagnostic logs.${includePerformance ? ' Flutter frame performance will also be recorded.' : ''}',
        ),
        actions: [
          TextButton(
            onPressed: () => Navigator.pop(c, false),
            child: const Text('Cancel'),
          ),
          FilledButton(
            onPressed: () => Navigator.pop(c, true),
            child: const Text('Start recording'),
          ),
        ],
      ),
    );
    final allowed = await Navigator.of(
      context,
      rootNavigator: true,
    ).push(route);
    await route.completed;
    if (allowed == true &&
        _active &&
        !_disposed &&
        _generation == promptGeneration) {
      _recording = true;
      _frameBudgetMs = frameBudgetMs;
      _performanceEnabled = includePerformance;
      if (_performanceEnabled) {
        SchedulerBinding.instance.addTimingsCallback(_onFrameTimings);
      }
      _replayEnabled = includeReplay;
      _generation++;
      _clear();
      _recordingPromptOpen = false;
      record('session', 'Recording started');
      if (_replayEnabled) {
        _timer = Timer.periodic(const Duration(seconds: 2), (_) => _sample());
      }
    }
  } finally {
    _recordingPromptOpen = false;
    _notifyUi();
  }
}