CkText constructor

const CkText({
  1. required String text,
  2. Key? key,
  3. int? maxLines,
  4. TextAlign textAlign = TextAlign.center,
  5. double left = 0,
  6. double right = 0,
  7. double top = 0,
  8. double bottom = 0,
  9. double? fontSize,
  10. FontWeight? fontWeight,
  11. Color? textColor,
  12. TextStyle? style,
  13. TextOverflow? overflow,
  14. bool? enableBorder = false,
  15. Color? borderColor,
  16. double? borderRadious,
  17. Color? backgroundColor,
  18. MainAxisAlignment? alignment,
  19. BorderRadius? borderRadiusOnly,
  20. Widget? suffix,
  21. Widget? preffix,
  22. bool isDescription = false,
  23. double? textHeight,
  24. bool autoResize = true,
  25. double minFontSize = 10,
  26. double? maxAutoFontSize,
  27. double stepGranularity = 0.5,
  28. bool? softWrap,
  29. Color? decorationColor,
  30. TextDecoration? decoration,
  31. TextDirection? textDirection,
  32. double? height,
  33. double textSpacing = 10,
  34. double textScaleFactor = .9,
  35. bool preventScaling = false,
  36. Gradient? gradient,
  37. int? decimalPlaces = 2,
})

Implementation

const CkText({
  required this.text,
  super.key,
  this.maxLines,
  this.textAlign = TextAlign.center,

  /// Responsive left padding applied to the text container via ScreenUtil (`left.w`).
  ///
  /// - Unlike standard Flutter [Text], which requires an external [Padding] widget,
  ///   [CkText] embeds responsive padding directly.
  /// - Default: `0`.
  this.left = 0,

  /// Responsive right padding applied to the text container via ScreenUtil (`right.w`).
  ///
  /// - Unlike standard Flutter [Text], which requires an external [Padding] widget,
  ///   [CkText] embeds responsive padding directly.
  /// - Default: `0`.
  this.right = 0,

  /// Responsive top padding applied to the text container via ScreenUtil (`top.h`).
  ///
  /// - Unlike standard Flutter [Text], which requires an external [Padding] widget,
  ///   [CkText] embeds responsive padding directly.
  /// - Default: `0`.
  this.top = 0,

  /// Responsive bottom padding applied to the text container via ScreenUtil (`bottom.h`).
  ///
  /// - Unlike standard Flutter [Text], which requires an external [Padding] widget,
  ///   [CkText] embeds responsive padding directly.
  /// - Default: `0`.
  this.bottom = 0,

  /// Direct convenience shortcut for font size in logical pixels without creating a [TextStyle].
  ///
  /// - Overrides `style?.fontSize`.
  /// - Falls back to `12.0` if both [fontSize] and `style?.fontSize` are `null`.
  this.fontSize,

  /// Direct convenience shortcut for font weight without creating a [TextStyle].
  ///
  /// - Overrides `style?.fontWeight`.
  /// - Falls back to `FontWeight.w400` if both [fontWeight] and `style?.fontWeight` are `null`.
  this.fontWeight,

  /// Direct convenience shortcut for text color without creating a [TextStyle].
  ///
  /// - Overrides `style?.color`.
  /// - In HTML mode, falls back to `effectiveTextStyle.color` or [Colors.black].
  this.textColor,
  this.style,
  this.overflow,

  /// Whether to wrap the text inside a bordered container card.
  ///
  /// - `true`: Renders a decorated [Container] with border, border radius, margin, and padding.
  /// - `false` (Default): Renders the text without an outer border container.
  /// - Note: If [backgroundColor] is provided, container rendering is automatically enabled.
  this.enableBorder = false,

  /// Border color for the surrounding container when [enableBorder] is `true`.
  ///
  /// - Falls back to `Theme.of(context).dividerColor` if `null`.
  this.borderColor,

  /// Uniform border radius in logical pixels (scaled via ScreenUtil `.r`) for the container.
  ///
  /// - Defaults to `4.r` if `null`.
  this.borderRadious,

  /// Background color for the text container.
  ///
  /// - When specified, automatically enables container rendering even if [enableBorder] is `false`.
  /// - Falls back to `coreKitInstance.backgroundColor` when container is active.
  this.backgroundColor,

  /// Alignment for the inner row/content layout.
  this.alignment,

  /// Directional [BorderRadius] for custom corner rounding (e.g., [BorderRadius.only]).
  ///
  /// - Overrides [borderRadious] when provided.
  this.borderRadiusOnly,

  /// A trailing widget (e.g., [Icon], checkmark, or badge) placed immediately after the text.
  ///
  /// - Spaced from the text by [textSpacing].
  /// - Rendered alongside the text in a horizontal [Row].
  this.suffix,

  /// A leading widget (e.g., [Icon], avatar, or badge) placed immediately before the text.
  ///
  /// - Spaced from the text by [textSpacing].
  /// - Rendered alongside the text in a horizontal [Row].
  this.preffix,

  /// Whether to render the text as an unscaled paragraph or description.
  ///
  /// - `true`: Disables auto-shrink fitting ([FittedBox] / adaptive binary scaling) and renders standard text.
  /// - `false` (Default): Uses auto-scaling based on [preventScaling] and [autoResize].
  this.isDescription = false,

  /// Absolute line height in logical pixels.
  ///
  /// - Unlike Flutter's [TextStyle.height] which takes a multiplier, [textHeight] accepts
  ///   pixels and converts it automatically: `(textHeight / effectiveFontSize)`.
  this.textHeight,

  /// Whether to automatically resize the text to fit within available space.
  ///
  /// - `true` (Default): Scales down using [FittedBox] or binary search adaptive sizing to prevent truncation.
  /// - `false`: Uses standard fixed text sizing.
  this.autoResize = true,

  /// Minimum font size threshold in logical pixels when auto-scaling multiline text.
  ///
  /// - Used in adaptive multiline mode when [maxLines] > 1 and [preventScaling] is `false`.
  /// - Default: `10`.
  this.minFontSize = 10,

  /// Maximum font size ceiling in logical pixels when auto-scaling multiline text.
  ///
  /// - Defaults to `style?.fontSize` or `24.0` if `null`.
  this.maxAutoFontSize,

  /// Font size step granularity resolution during binary search in adaptive multiline mode.
  ///
  /// - Default: `0.5`.
  this.stepGranularity = 0.5,
  this.softWrap,

  /// Direct convenience shortcut for text decoration line color without creating a [TextStyle].
  ///
  /// - Corresponds to [TextStyle.decorationColor].
  /// - Overrides `style?.decorationColor`.
  this.decorationColor,

  /// Direct convenience shortcut for text decoration (e.g. underline, line-through) without creating a [TextStyle].
  ///
  /// - Corresponds to [TextStyle.decoration].
  /// - Overrides `style?.decoration`.
  this.decoration,
  this.textDirection,

  /// Direct convenience shortcut for line height multiplier without creating a [TextStyle].
  ///
  /// - Corresponds to [TextStyle.height].
  /// - Overrides `style?.height`.
  this.height,

  /// Horizontal gap spacing in logical pixels between the text and [preffix] or [suffix] widgets.
  ///
  /// - Default: `10`.
  this.textSpacing = 10,

  /// Text scale factor multiplier applied to the text widget.
  ///
  /// - Default: `.9`.
  this.textScaleFactor = .9,

  /// Whether to prevent automatic text scaling down.
  ///
  /// - `true`: Disables [FittedBox] and adaptive multiline sizing, rendering standard unscaled Flutter [Text].
  /// - `false` (Default): Enables auto-scaling down to fit available bounds.
  this.preventScaling = false,

  /// Gradient shader applied across the text glyphs via [ShaderMask].
  ///
  /// - Uses [BlendMode.srcIn] to paint smooth gradient colors onto the text.
  this.gradient,

  /// The number of decimal places to format floating-point numbers found in [text].
  ///
  /// Configurable behaviors:
  /// - `2` (Default): Standard currency/price rounding (e.g., `12.345` -> `12.35`).
  /// - `1`: Precision metrics or ratings (e.g., `4.89` -> `4.9`).
  /// - `0`: Rounds to the nearest integer (e.g., `12.345` -> `12`).
  /// - `null`: Completely disables automatic number formatting (useful for versions like `v1.0.4`, GPS coordinates, or codes).
  this.decimalPlaces = 2,
});