CPVoiceControlState constructor

CPVoiceControlState({
  1. required String identifier,
  2. List<String>? titleVariants,
  3. String? image,
  4. bool repeats = false,
  5. List<CPButton> actionButtons = const [],
})

Implementation

CPVoiceControlState({
  required this.identifier,
  List<String>? titleVariants,
  this.image,
  this.repeats = false,
  List<CPButton> actionButtons = const [],
}) : titleVariants = titleVariants == null
         ? null
         : List.unmodifiable(titleVariants),
     actionButtons = List.unmodifiable(actionButtons) {
  if (identifier.trim().isEmpty) {
    throw ArgumentError.value(identifier, 'identifier', 'Must not be empty.');
  }
  if (titleVariants != null &&
      (titleVariants.isEmpty || titleVariants.any((s) => s.trim().isEmpty))) {
    throw ArgumentError.value(
      titleVariants,
      'titleVariants',
      'Provide nonempty titles or omit them.',
    );
  }
  if (image != null && image!.trim().isEmpty) {
    throw ArgumentError.value(image, 'image', 'Must not be empty.');
  }
  if (actionButtons.map((b) => b.uniqueId).toSet().length !=
      actionButtons.length) {
    throw ArgumentError('A voice state requires distinct action buttons.');
  }
}