Example 4 Let the inequality
$$
x^{2}-(a+1) x-a^{2}>0
$$

hold for all $a \in(1,2)$. Find the range of $x$.
【Analysis】In this inequality, the parameter $a$ has both quadratic and linear terms, which makes it difficult to handle. Instead of treating $x$ as the main variable, we can view the original inequality as a quadratic inequality in $a$ with $x$ as a parameter, and then find the range of $x$.
The original inequality can be rewritten as
$$
a^{2}+x a+\left(x-x^{2}\right)<0 \text {. }
$$

Let $g(a)=a^{2}+a x+\left(x-x^{2}\right)<0$ hold for all $a \in(1,2)$, then $g(1) \leqslant 0$, and $g(2) \leqslant 0$. Thus,
$$
\left\{\begin{array}{l}
1+2 x-x^{2} \leqslant 0, \\
4+3 x-x^{2} \leqslant 0 .
\end{array}\right.
$$

Therefore, $x \geqslant 4$ or $x \leqslant-1$.