Preheat oven to 375 degrees F (190 degrees C). Grease a 9×13-inch baking dish.
Spread about 1/3 of the potato slices into the bottom of the prepared baking dish. Top with about 1/3 of the onion slices. Sprinkle 3 tablespoons flour over the potato and onion. Arrange 2 tablespoons butter atop the flour. Season the entire layer with salt and pepper. Repeat layering twice more.
Heat milk in a saucepan until warm. Pour enough warm milk over the mixture in the baking dish so the top of the liquid is level with the final layer of potatoes.
Bake in preheated oven until potatoes are tender, 45 to 60 minutes.