is there a way to get perfectly flat cupcakes??
Under fill your cup cake pan/ line small ramekins will cupcake liners, and under fill/ cut off the muffin tops.
you could skip the leavening (baking powder and/or soda) but I don't recommend it. I think that's why there are special cake pans for such things.
you can always trim the tops to be level with the cupcake liners, as i'd assume you'll be topping them with something if you want them flat. (Why do you want them flat?)
You have to cut off the top to make them flat. If there were a trick to perfectly risen, yet still flat-topped cakes I'm pretty sure bakers would be using it to cut out the rather tricky step of trimming later on.