What's the proper way to manage variations across build variants for white label apps?

I've worked with some white label apps, but I still don't know the proper answer to this.

Is the answer simply to have all common code in the main source set, and to have all varying code in specific variant source sets?

One issue I see is what if you had a view model in the main source set, then suddenly this view model needs to do something slightly different for one build variant.

Do you end up copying and pasting the whole view model, duplicating it into that variant source set, then editing the code for its needs? Then you are stuck with making sure every future change in the main view model, also needs to be copied over to the variant view model.