RemoteKillSwitchPanel constructor

RemoteKillSwitchPanel({
  1. Key? key,
  2. required List<KillSwitchItem> items,
  3. required Future<void> onKillLocally(
    1. String id
    ),
  4. required Future<void> onClearOverride(
    1. String id
    ),
  5. bool busy = false,
  6. String title = 'Feature safety switches',
  7. String killedLabel = 'Killed',
  8. String activeLabel = 'Active',
  9. String killLabel = 'Kill locally',
  10. String confirmKillLabel = 'Confirm local kill',
  11. String clearLabel = 'Clear local override',
  12. String confirmationText = 'This only kills the feature on this device. It cannot enable a remotely killed feature.',
  13. String cancelLabel = 'Cancel',
  14. String errorLabel = 'Could not apply this change. Please try again.',
  15. String emptyLabel = 'No feature switches.',
})

Implementation

RemoteKillSwitchPanel({
  super.key,
  required List<KillSwitchItem> items,
  required this.onKillLocally,
  required this.onClearOverride,
  this.busy = false,
  this.title = 'Feature safety switches',
  this.killedLabel = 'Killed',
  this.activeLabel = 'Active',
  this.killLabel = 'Kill locally',
  this.confirmKillLabel = 'Confirm local kill',
  this.clearLabel = 'Clear local override',
  this.confirmationText =
      'This only kills the feature on this device. It cannot enable a remotely killed feature.',
  this.cancelLabel = 'Cancel',
  this.errorLabel = 'Could not apply this change. Please try again.',
  this.emptyLabel = 'No feature switches.',
}) : items = List.unmodifiable(items) {
  final ids = <String>{};
  for (final item in items) {
    if (!ids.add(item.id)) {
      throw ArgumentError.value(item.id, 'items', 'duplicate id');
    }
  }
  for (final (name, value) in [
    ('title', title),
    ('killedLabel', killedLabel),
    ('activeLabel', activeLabel),
    ('killLabel', killLabel),
    ('confirmKillLabel', confirmKillLabel),
    ('clearLabel', clearLabel),
    ('confirmationText', confirmationText),
    ('cancelLabel', cancelLabel),
    ('errorLabel', errorLabel),
    ('emptyLabel', emptyLabel),
  ]) {
    if (value.trim().isEmpty) {
      throw ArgumentError.value(value, name, 'must not be blank');
    }
  }
}