Hansi Flick has been appointed as the head coach of Germany on three-year deal starting after the European Championship this summer.