How to check if the page is front page?
This is indeed a way to check if it is the front page and should return a value if you check the method code.

I am using it in a few preprocess hooks:

$variables['is_front'] = \Drupal::service('path.matcher')-&gt;isFrontPage();