Blueprint is somehow null

Hi there,

I’m stuck with a form for a plugin. I’m trying to get the icon of a blueprint but there is some strange behaviour.

$templates = $page->blueprint()->pages()->template();

foreach($modules as $module) {
  
  // modules.text or modules.gallery
  $template = $module->intendedTemplate();
  
  // Error
  // Call to a member function icon() on null
  $templates->findBy('name', $template)->icon();

  // Works
  $templates->findBy('name', 'module.text')->icon();

}

It is not limited to the icon method since the returned object is null. But actually the blueprint object im working with is not null.

$templates = $page->blueprint()->pages()->template();

foreach($modules as $module) {
  
  // modules.text or modules.gallery
  $template = $module->intendedTemplate();
  
  $blueprint = $templates->findBy('name', $template);
  dump($blueprint);

  // Kirby\Panel\Models\Page\Blueprint Object
  // (
  //   [name] => module.text
  //   [file] => /var/www/public/site/modules/text/text.yml
  //   ...


  $blueprint = $templates->findBy('name', 'module.text')->icon();
  dump($blueprint);

  // Kirby\Panel\Models\Page\Blueprint Object
  // (
  //   [name] => module.text
  //   [file] => /var/www/public/site/modules/text/text.yml
  //   ...
}

I am a bit lost here. Perhaps someone has some insight?