How to check when animation made in Animation view stops playing?

I’ve tried animation.IsPlaying but I always get an error. I’ve read that these are for fbx files so I can’t use it. I’m using sprites, is there a way to detect when these finish. Can’t find anything in the docs

if (this.animator.GetCurrentAnimatorStateInfo(0).IsName(“YourAnimationName”))
{
//animation is playing
}

Found it here: How can I check if an animation is playing or has finished? (Using Animator/C#) - Unity Answers