Flashing vs steady bike lights

Which is safest and what does the law say? Most front and rear bike lights have the option to run in either a steady or flashing mode. Does one make you more visible on the road than the other? Can flashing lights pose a danger to other road users? And are flashing lights even legal?…