improve get current platform logic

This commit is contained in:
AmirHossein Abdolmotallebi 2024-09-18 17:34:51 +03:30
parent 8ef83d8e7c
commit 935d61f08c

View File

@ -44,7 +44,11 @@ interface PlatformFInder {
}
private class JvmPlatformFinder : PlatformFInder {
override fun getCurrentPlatform(): Platform {
private val _platform by lazy {
getCurrentPlatformFromJVMProperty()
}
private fun getCurrentPlatformFromJVMProperty(): Platform {
val osString = System.getProperty("os.name").lowercase()
return when {
osString.contains("android") -> Android
@ -54,6 +58,10 @@ private class JvmPlatformFinder : PlatformFInder {
else -> error("this platform is not detected: $osString")
}
}
override fun getCurrentPlatform(): Platform {
return _platform
}
}
sealed interface DesktopPlatform