My player's dash move goes through walls

using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine;

public class PlayerMovement : MonoBehaviour{
    public float moveSpeed = 5f;
    private Rigidbody2D rb;
 
    Vector2 Movement;
    Vector3 lastMoveDir;
 
    public int maxHealth = 10;
    public int currentHealth;
 
    public float dashSpeed;
    public float dashCoolDown = 3;
 
    public HealthBarScript healthBar;
 
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        currentHealth = maxHealth;
        healthBar.SetMaxHealth(maxHealth);
    }
 
 
    void Update()
    {
           
        Movement.x = Input.GetAxisRaw("Horizontal");
        Movement.y = Input.GetAxisRaw("Vertical");
 
        void TakeDamage(int damage)
        {
            currentHealth -= damage;
            healthBar.SetHealth(currentHealth);
        }
        DashMove();
    }
 
    void FixedUpdate()
    {
        dashCoolDown -= Time.deltaTime;
        if(dashCoolDown <= 0)
        {
            dashCoolDown = 0;
        }
        rb.MovePosition(rb.position + Movement * moveSpeed * Time.fixedDeltaTime);
        lastMoveDir = Movement;
    }
 
    public void DashMove()
    {
        if (Input.GetKeyDown(KeyCode.Space) && dashCoolDown == 0)
        {
            transform.position += lastMoveDir * dashSpeed;
            dashCoolDown = 2f;
        }
    }
}

this might be late but, your code is similar to code monkeys code your solution is in his video(he created a raycast to check if there is a collider) How to Make Simple Character Dash Ability - Code Monkey