You can do it either way,
If this is a replacement, then you may have to shim to level the new tub.
That will leave a gap and some shims at one end.
By installing the tub first, you can shim, then put the underlayment up to the tub, hiding the gap, and holding the tub tight to the alcove walls.
It also makes it less of a step to get into the tub.
The best choice is to install the tub first,
And then the flooring.