  We develop a model to explain the flaring activity in gamma-ray burst X-ray
afterglows within the framework of slightly misaligned observers to structured
jets. We suggest that flares could be the manifestation of prompt dissipation
within the core of the jet, appearing to a misaligned observer in the X-ray
band because of less favorable Doppler boosting. These flares appear during the
afterglow phase because of core--observer light travel delays. In this picture,
the prompt emission recorded by this observer comes from material along their
line of sight, in the lateral structure of the jet, outside the jet's core. We
start by laying down the basic analytical framework to determine the flares
characteristics as a function of those of the gamma-ray pulse an aligned
observer would see. We show that there is viable parameter space to explain
flares with typical observing times and luminosities. We then analytically
explore this model, showing that it naturally produces flares with small aspect
ratios, as observed. We perform fits of our model to two $Swift$/XRT flares
representing two different types of morphology, to show that our model can
capture both. The ejection time of the core jet material responsible of the
flare is a critical parameter. While it always remains small compared to the
observed time of the flare, confirming that our model does not require very
late central engine activity, late ejection times are strongly favored,
sometimes larger than the observed duration of the parent gamma-ray burst's
prompt emission as measured by $T_{90}$.
