Skip to content

Instantly share code, notes, and snippets.

View AsadLeo1995's full-sized avatar
🎯
Focusing

Asad Mahmood AsadLeo1995

🎯
Focusing
View GitHub Profile
@AsadLeo1995
AsadLeo1995 / UiText.kt
Last active April 8, 2023 10:26
Error handling in kotlin when you have both string & string resource error. Credit @philipplackner
import android.content.Context
import androidx.annotation.StringRes
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
sealed class UiText{
data class DynamicString(val value: String): UiText()
data class StringResource(@StringRes val id: Int,val args: List<Any>): UiText()