CkText constructor
const
CkText({
- required String text,
- Key? key,
- int? maxLines,
- TextAlign textAlign = TextAlign.center,
- double left = 0,
- double right = 0,
- double top = 0,
- double bottom = 0,
- double? fontSize,
- FontWeight? fontWeight,
- Color? textColor,
- TextStyle? style,
- TextOverflow? overflow,
- bool? enableBorder = false,
- Color? borderColor,
- double? borderRadious,
- Color? backgroundColor,
- MainAxisAlignment? alignment,
- BorderRadius? borderRadiusOnly,
- Widget? suffix,
- Widget? preffix,
- bool isDescription = false,
- double? textHeight,
- bool autoResize = true,
- double minFontSize = 10,
- double? maxAutoFontSize,
- double stepGranularity = 0.5,
- bool? softWrap,
- Color? decorationColor,
- TextDecoration? decoration,
- TextDirection? textDirection,
- double? height,
- double textSpacing = 10,
- double textScaleFactor = .9,
- bool preventScaling = false,
- Gradient? gradient,
- 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,
});