For consistency, withXXX methods should return the last value of the passed lambda
with from Kotlin stdlib returns value of its last expression, if any, and in other places of the Kotlin world, withXXX methods do the same to follow this convention, yet in androidx they return Unit as seen there: https://android.github.io/android-ktx/core-ktx/androidx.graphics/android.graphics.-canvas/index.html
This should be fixed for the sake of consistency.
I'd be open to returning the Canvas. I don't see much reason to return from the lambda though.
If the methods don't return the last expression, they shouldn't be named withXXX IMHO.
doWithXXX or applyWithXXX would be less confusing in regards to the naming convention. The do variant may return Unit and the apply variant, the Canvas, following what apply from Kotlin stdlib does.