Say we have a differential equation $\frac{dx}{dt}= -ax+b$
We can find the solution by solving $\frac{dx}{dt}= -ax$:
$$x_r=Ae^{-at}$$ And then adding a "particular solution" for $\frac{dx}{dt}=0$, which results in $x_p=\frac{b}{a}$ then we simply add these solutions, and solve for $A$:
$$x=(x_0-\frac{b}{a})e^{-at}+\frac{b}{a}$$
We can easily verify afterwards that this solves the differential equation by taking the derivative now, and seeing that it satisfies it.
My question, however: Is there a method to actually derive this solution, without having to guess beforehand that we can simply add those two solutions separately?
Or at the very least, is there a more general method from which this particular approach follows?