Contravariant Vector Component Transformation from Polar to Cartesian

I am new to tensors and I have just learned that the contravarient components of a vector transforms in the following way (using Einstein summation convention) $$A^{'i}=\frac {\partial x^{'i}}{\partial x^j}A^j$$ I want to transform the components of a vector from polar $$(r,\theta)$$ coordinate to cartesian $$(x,y)$$ coordinate. So, I use $$x^{'1}=x, x^{'2}=y, x^1=r$$ and $$x^2=\theta$$. Also, $$x=r\cos\theta$$ and $$y=r\sin\theta$$. After performing the partial derivatives, I obtain the transformation matrix as $$\begin{pmatrix} \cos\theta & -r\sin\theta \\ \sin\theta & r\cos\theta \\ \end{pmatrix}$$ But, I know from my basic vector studies that $$\hat r=\cos \theta \hat x + \sin \theta \hat y$$ $$\hat \theta=-\sin \theta \hat x + \cos \theta \hat y$$ So, $$\vec A=A_x\hat x+A_y\hat y=A_r\hat r+A_\theta\hat \theta=(A_r\cos \theta-A_\theta\sin \theta)\hat x+(A_r\sin \theta+A_\theta\cos \theta)\hat y$$

Now, equating the $$\hat x$$ and $$\hat y$$ components, we obtain the transformation matrix as $$\begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \\ \end{pmatrix}$$ Can anyone please explain why this discrepancy arises? Have I misunderstood something? What am I doing wrong here?

$$\hat{r} = \frac{\partial}{\partial r} = \frac{\partial x}{\partial r} \frac{\partial}{\partial x} + \frac{\partial y}{\partial r} \frac{\partial}{\partial y}$$ $$= \cos\theta \hat{x} + \sin\theta\hat{y}$$
$$\hat{\theta} = \frac{\partial}{\partial \theta }= \frac{\partial x}{\partial \theta} \frac{\partial}{\partial x} + \frac{\partial y}{\partial \theta } \frac{\partial}{\partial y}$$ $$= - r \sin \theta \hat{x} + r \cos\theta\hat{y}$$
However, basis $$\hat{\theta}$$ is not normalized yet. Its magnitude is varied at each point. We can use this magnitude-varying basis, but basis is usually defiend with normalization for convinient. By this rescaling, transformation matrix is also changed.