copyWith method

AgentConfiguration copyWith({
  1. String? appKey,
  2. String? collectorURL,
  3. String? screenshotURL,
  4. bool? screenshotsEnabled,
  5. LoggingLevel? loggingLevel,
  6. CrashReportCallback? crashReportCallback,
  7. bool? crashReportingEnabled,
  8. String? applicationName,
  9. bool? enableLoggingInVSCode,
})

Creates a new AgentConfiguration with possibility to overwrite existing properties.

Useful when needing to conditionally add properties, as with a boolean flag variable.

AgentConfiguration config = AgentConfiguration(appKey: "ABC-DEF-GHI");

if (shouldEnableLogging) {
   config = config.copyWith(loggingLevel: LoggingLevel.verbose);
}

await Instrumentation.start(config);

Implementation

AgentConfiguration copyWith(
    {String? appKey,
    String? collectorURL,
    String? screenshotURL,
    bool? screenshotsEnabled,
    LoggingLevel? loggingLevel,
    CrashReportCallback? crashReportCallback,
    bool? crashReportingEnabled,
    String? applicationName,
    bool? enableLoggingInVSCode}) {
  return AgentConfiguration(
      appKey: appKey ?? this.appKey,
      collectorURL: collectorURL ?? this.collectorURL,
      screenshotURL: screenshotURL ?? this.screenshotURL,
      screenshotsEnabled: screenshotsEnabled ?? this.screenshotsEnabled,
      loggingLevel: loggingLevel ?? this.loggingLevel,
      crashReportCallback: crashReportCallback ?? this.crashReportCallback,
      crashReportingEnabled:
          crashReportingEnabled ?? this.crashReportingEnabled,
      applicationName: applicationName ?? this.applicationName,
      enableLoggingInVSCode:
          enableLoggingInVSCode ?? this.enableLoggingInVSCode);
}