It is possible for flowers to spawn in caves underground if a dirt patch is near a pool of lava. The lava provides sufficient light levels for the flower to be generated. This also applies to tall grass.
Linked issues
Comments 3
Just want to comment on this further. I found 2 poppies growing in complete darkness underground. Is this truly intended or will nearby (but obscured) lava allow growth in total darkness?
Intended, linked to MC-30755
This is partially intended as it's the worldgen doing this.