ktx
ktx copied to clipboard
scene2d image without drawable
Hi,
right now the image
scene2d extension requires a non-null Drawable
:
@Scene2dDsl
@OptIn(ExperimentalContracts::class)
inline fun <S> KWidget<S>.image(
drawable: Drawable,
init: (@Scene2dDsl Image).(S) -> Unit = {},
): Image {
contract { callsInPlace(init, InvocationKind.EXACTLY_ONCE) }
return actor(Image(drawable), init)
}
However, it is valid to pass "null" as a drawable and this can be useful if the real drawable is set later on but you still want to add the image to the table to have the correct layout.
Would it be okay to make it Drawable?
instead of Drawable
? This might be also true for other extensions with drawables but I did not check them all.
Or is there a different solution to it?