but I cannot find a way to populate the src value.
(also, please let me know if this is not the right place to ask this)
🙏 1
Alex Styl
12/09/2021, 1:39 PM
Couldn’t find a way to do it so I created (copy-pasted) my own CssProperty. Seems to be working
Copy code
var StyledElement.src: String by CssProperty()
// copy pasted in my file to be accessible
private class CssProperty<T>(private val default: (() -> T)? = null) {
operator fun getValue(thisRef: StyledElement, property: KProperty<*>): T {
default?.let { default ->
if (!thisRef.declarations.containsKey(property.name)) {
thisRef.declarations[property.name] = default() as Any
}
}
@Suppress("UNCHECKED_CAST")
return thisRef.declarations[property.name] as T
}
operator fun setValue(thisRef: StyledElement, property: KProperty<*>, value: T) {
thisRef.declarations[property.name] = value as Any
}
}
m
Matteo Mirk
12/09/2021, 2:50 PM
wow, so you had to copy CssProperty, which is private in Ktor, and modify it to your needs? If you think this is a missing feature you should open a PR to Ktor.