Prepare your working environment. Preheat the oven to 375 F (190 C).
Line a 9 x 13-inch baking dish with parchment paper or grease with butter. Thinly slice potatoes and onions. Arrange 1/3 of the potato slices in an even layer in the pan, then top with 1/3 of the onions. Sprinkle flour, salt, and pepper over the layer, then arrange about 2 tbsp of cut-up butter on top.
Repeat step 2 twice until you use up all your potatoes.
Heat 3 cups of whole milk until it is warm (not boiling). Pour the milk over the potatoes, stopping when the liquid reaches the top of the layered potatoes.
Bake for 45-60 minutes, until the potatoes are tender, when you prick them with a fork.