Get fields from a collection field in .theme
Use the following code:

$fieldCollectionItems = $node-&gt;get('field_collection_gallery');

    foreach ($fieldCollectionItems as $key =&gt; $item) {
      $fcItem = FieldCollectionItem::load($item-&gt;value);

      if ($fcItem instanceof FieldCollectionItem) {
        $fcValue = $fcItem-&gt;get('field_name')-&gt;getValue();
      }
    }


The $fcValue variable should contain the value from the field in the field collection item.

You have to replace the field_name with your own field name in the last line in the foreach() loop.