First-principles theory of flexoelectricity : methods and applications