Do you want to know how to Drupal?

Let's Drupal

How to check if the current page using admin theme in Drupal?

To check this we need to use router.admin_context service

if (\Drupal::service('router.admin_context')->isAdminRoute()) {
   // Do something here.
}

We also can check a specific route

$route_provider = \Drupal::service('router.route_provider');
$route = $route_provider->getRouteByName('user.page');
if (\Drupal::service('router.admin_context')->isAdminRoute($route)) {
   // Do something here.
}