ContrastPreviewCard constructor

ContrastPreviewCard({
  1. Key? key,
  2. required Color foreground,
  3. required Color background,
  4. required String sampleText,
  5. double? threshold,
  6. bool largeText = false,
  7. VoidCallback? onTap,
  8. String? semanticLabel,
  9. String passLabel = 'Pass',
  10. String failLabel = 'Needs more contrast',
})

Implementation

ContrastPreviewCard({
  super.key,
  required this.foreground,
  required this.background,
  required this.sampleText,
  this.threshold,
  this.largeText = false,
  this.onTap,
  this.semanticLabel,
  this.passLabel = 'Pass',
  this.failLabel = 'Needs more contrast',
}) {
  if (sampleText.trim().isEmpty) {
    throw ArgumentError.value(sampleText, 'sampleText', 'must not be blank');
  }
  final requestedThreshold = threshold;
  if (requestedThreshold != null &&
      (!requestedThreshold.isFinite || requestedThreshold <= 0)) {
    throw ArgumentError.value(
      threshold,
      'threshold',
      'must be finite and > 0',
    );
  }
  for (final (name, value) in [
    ('semanticLabel', semanticLabel),
    ('passLabel', passLabel),
    ('failLabel', failLabel),
  ]) {
    if (value != null && value.trim().isEmpty) {
      throw ArgumentError.value(value, name, 'must not be blank');
    }
  }
}