That’s where your method becomes considerably more hassle than just eyeballing it
Without a doubt, and I just eyeball it normally but if you are very picky about it being straight and suffering from a bad case of stem blindness, there’s a way of getting it straight.
When I was building bikes full time I just nipped it up approximately straight, set up the levers, cables etc and only did the headset and stem at the very end when I lifted the bike out the stand. Either that or swung the bike front wheel down enough that I could easily look straight down on the top of the bars, albeit from in front of the bike, not riding position.