How to cut 2d light with walls?

I am using global light 2d to make a scene dark and then I use a sprite light 2d to make a triangle flashlight. I want the flashlight to “cut” its shape when it reaches a wall rather than go through it. This is a top down 2d game, how can I achieve this? I’m still learning c# so if you could explain your code I would really appreciate it. Thanks!

I believe you are looking for ShadowCaster2D
This component should allow the behavior you are describing.