Dash problem with colliding objects

I’m making a 2D TopDown game in which the character has the ability to dash. But when I dash the character can get stuck in another object that has a RigidBody2D.

How can I make the character stop when he collides with an object?

Dash method:

private void Dash()
{
    if(Input.GetKeyDown(KeyCode.Space) && canDash && BasicFunctions.NotCooldown(dashCooldown, ref lastTimeDash))
    {
        animator.SetTrigger("dash");
        rb.velocity = new Vector2(movementInput.x * dashSpeed, movementInput.y * dashSpeed);
    }
}

Moving method:

private bool TryMove(Vector2 direction)
{
    if(direction != Vector2.zero)
    {
        int count = rb.Cast(
            direction,
            movementFilter,
            castCollisions,
            moveSpeed * Time.fixedDeltaTime + collisionOffset);

        if (count == 0)
        {
            rb.MovePosition(rb.position + direction * moveSpeed * Time.fixedDeltaTime);
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}