Flexible optoelectronic devices based on metal halide perovskites