package com.pixelized.desktop.lwa.utils.extention

import com.pixelized.desktop.lwa.ui.composable.textfield.LwaTextFieldUio

inline fun <reified T> LwaTextFieldUio.unpack(): T? {
    if (errorFlow.value) return null
    val value = valueFlow.value.ifBlank { placeHolder }
    return when (T::class) {
        String::class -> value
        Float::class -> value?.toFloatOrNull()
        Int::class -> value?.toIntOrNull()
        else -> null
    } as T?
}