By Grauert-Fischer Theorem, a smooth family of compact complex manifold is locally trivial if and only if all the fibers are analytically isomorphic.
However, there exist smooth families $\pi \colon X \to B$ such that the fibres are not isomorphic, and so they are not locally trivial.
The easiest examples occur already for $\dim X =2$ and $\dim B =1$: they are the so-called Kodaira fibrations. In such fibrations, all the fibres are smooth curves but their complex structure varies. Moreover,
If $X$$\pi \colon X \to B$ is projective, hence Kaelera Kodaira fibration, andthen $B$ is a curve of genus at least $2$. Furthermore, $X$ is a minimal surface of general type, hence it is algebraic and $K_X$ is ample.
So, even imposing a positivity condition on $K_X$, the answer to your question is no.
A reference is [Barth-Hulek-Peters-Van de Ven, Compact Complex Surfaces], Chapter V.
For the Grauert-Fischer theorem see the same book, Chapter I.