  Ferroelastic twin walls in nonpolar materials can give rise to a spontaneous
polarization due to symmetry breaking. Nevertheless, the bi-stable polarity of
twin walls and its reversal have not yet been demonstrated. Here, we report
that the polarity of SrTiO$_3$ twin walls can be switched by ultra-low strain
gradient. Using first-principles-based machine-learning potential, we
demonstrate that the twin walls can be deterministically rotated and realigned
in specific directions under strain gradient, which breaks the inversion
symmetry of a sequence of walls and leads to a macroscopic polarization. The
system can maintain polarity even after the strain gradient is removed. As a
result, the polarization of twin walls can exhibit ferroelectric-like
hysteresis loop upon cyclic bending, namely ferro-flexoelectricity. Finally, we
propose a scheme to experimentally detect the polarity of twin wall by
measuring the bulk photovoltaic responses. Our findings suggest a
twin-wall-mediated ferro-flexoelectricity in SrTiO$_3$, which could be
potentially exploited as functional elements in nano-electronic devices design.
