I have been reading the forums on how to solve the integral form of ampere's law and I have worked out that the correct way to solve it is to get rid of the dot product by realizing that $|B ∙ dr|$ is always $B dr$ because $\cos\theta$ is always $0$. The integrate across the circle. However my problem is that I original tried to solve this like any other line integral with the attached work. Somebody please explain why my reasoning is incorrect. I am new to vector calculus and am teaching myself so any help is appreciated. Thanks!
Attempt at a solution:
$$\int_C B\cdot dr = \mu_0I = \int_{t=a}^{t=b} B(\vec r(t))\cdot \vec r'(t)dt$$
$C$ is any circle with radius $r$. $x=r\cos(t)$, $y=r\sin(t)$.
$$\vec r(t) = r\cos(t)\hat i + r\sin(t)\hat j \\ \vec r'(t) = -r\sin(t)\hat i + r\cos(t)\hat j$$
Let $\vec B = \langle B_1, B_2\rangle$.
$$\int_{t=0}^{t=2\pi} \langle B_1, B_2\rangle \cdot \langle -r\sin(t),r\cos(t)\rangle\ dt \\ \int_{t=0}^{t=2\pi} \left[-B_1r\sin(t)+B_2r\cos(t)\right]\ dt \\ B_1r\cos(t) + B_2r\sin(t)\Big|_{t=0}^{t=2\pi} \\ Br + 0 \\ Br = \mu_0I \\ \bbox[5px,border:2px solid black]{B=\frac{\mu_0I}{r}} \\ \color{red}{B = \frac{\mu_0I}{2\pi r} \ \ ?}$$
I know the way to solve this problem to get rid of the dot product with $Bdr\cos(\theta)$ and to integrate wrt $B$ as constant and $C$ but where did I go wrong in my derivatino if I didn't know how to do that?