Yes, flour can be composted.
Flour and the paper bags it usually comes in both compost down pretty quickly so in theory you could just throw them in as they are – but it is better to rip open the bags and mix the flour into the rest of the compost heap for a couple of reasons.
Firstly, rodents love flour and can easily defeat paper packaging – mixing it in will help deter undesirable visitors to your plot. Secondly, a layer/lump of flour is pretty compact/dense and could reduce the air flow in your compost heap – again, stirring it into the heap will lessen that issue.
Also: You can also use out of date flour to make paper glue or play/modelling dough. If it’s infested with weevils, you can freeze it first to kill the little blighters.