in KMP, how do you normally do if you need to pass...
# multiplatform
m
in KMP, how do you normally do if you need to pass
Context
via constructor for example to the
androidMain
but you don’t need it in
iosMain
? Because you can’t do something like
Copy code
// commonMain expect fun createThemePreferences(): ThemePreferences
// androidMain actual fun createThemePreferences(context: Context): ThemePreferences { // Has no corresponding expected declaration
    return ThemePreferencesImpl(context)
}
e
What I did in my app was not
expect
the function directly but an interface. Then, I could inject
Context
into the actual class implementation and not need this information in the function itself.
m
Thanks!
s
@Manuel Lorenzo You can watch this video

https://www.youtube.com/watch?v=5qc24AQ6ktc

m
thanks! it looks a bit ugly tho - I don't want to have
KoinContext
inside my main composable. I'm also trying to do this to build a KMP library, not an app