Can I conditionally hide a route (e.g. action / local task) Consider an action button on a custom entity's canonical page:

mymodule.actions.yml:

entity.item.action:
  route_name: entity.item.action
  title: 'Do something'
  appears_on:
    - entity.item.canonical


mymodule.routing.yml:

entity.item.action:
  path: '/item/{item}/action'
  defaults:
    _controller: '\Drupal\mymodule\Controller\ItemController::action'
    _title: 'Do something'
  requirements:
    _permission: 'edit items'


I would like to show or hide the action button depending on the value of some field of the entity.

How could I achieve this? Would it be wise to add custom access checking for this?
You can add a custom access method on your controller. According to this page you should have access to your item argument in the access method so you should be able to restrict access based on a value on that item. The action should be hidden if the user does not have access to the route, i.e. your custom access method denies access.