how to test if a node is flagged in twig I would like to know how to test if a node is flagged.

In D7 : if ($ flag-> is_flagged ($ node-> nid)) But I discover D8 and I do not see how to do it with twig

thank you in advance
Write a function with hook preprocess_node in your custom module and set a custom variable isflagged ture or false
then check this variable in your twig file node is flagged or not 
like

/**
 * Implements hook_preprocess_node().
 */
function yourModuleName_preprocess_node(&amp;$variables) {
  $node = $variables['node']; // Just in case you need it

  if($variables['node']-&gt;getType() == "yourNodeType") {
    // your code 
    if ($flag-&gt;is_flagged ($node-&gt;id())){
      $variables['isFlagged'] = true;
    }else{
      $variables['isFlagged'] = false;
    }

  }
}


now in your twig

{% if  isFlagged %}
  //do some thing
{% endif %}


hope this helps you