title: I can succesfully show asset logo but i still get the error: Unable to load asset
body: <p>I have a use case where i have to load the asset image based on the value of the key <code>logo_image</code> from a json file.</p>
  <p>So i have this json with key <code>logo_image</code> and value <code>image1.png</code>:</p>
  <pre><code>{
    &quot;logo_image&quot; : &quot;image1.png&quot;
  }
  </code></pre>
  <p>There is an image inisde the assets folder like this: <code>assets/image1.png</code></p>
  <p>I have a class called <code>GetAssets()</code> with a method called <code>getAssetItems()</code> which loads the json file and another method called <code>getLogo</code> which i will use as blueprint in the view to specify which key item i want to view:</p>
  <pre><code>class GetAssets {
  
  Future&lt;Map&lt;String, dynamic&gt;&gt; getAssetItems() async {
      String jsonData =
          await rootBundle.loadString('assets/items.json');
      Map&lt;String, dynamic&gt; data = jsonDecode(jsonData);
      return data;
  
  
  
    Future getLogo(String key) async {
      var assets = await GetAssets().getAssetItems();
      return 'assets/' + assets[key];
    }
  }
  
  </code></pre>
  <p>I have a field called <code>logo</code> and i have method called <code>setAssets()</code> to load the logo and set the state of the logo with <code>setState()</code> and i use <code>initState()</code> to initialize <code>setAssets()</code>. I have a <code>Scaffold()</code> which i use to view the asset logo with the field <code>logo</code>:</p>
  <pre><code>import 'package:flutter/material.dart';
  
  class ShowLogo extends StatefulWidget {
    const ShowLogo({Key? key}) : super(key: key);
  
    @override
    _ShowLogoState createState() =&gt; _ShowLogoState();
  }
  
  class _ShowLogoState extends State&lt;ShowLogo&gt; {
    late String logo = &quot;&quot;;
    setAssets() async {
      final logoFromAsset = await GetAssets().getLogo(&quot;logo_image&quot;);
  
      setState(() {
        logo = logoFromAsset;
      });
    }
  
    @override
    initState() {
      setAssets();
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(body: Image.asset(logo),);
    }
  }
  
  </code></pre>
  <p>I am able to show the logo on the screen of my phone, but i still get the error: <code>Unable to load asset:</code> What is the cause of this? How can i resolve this issue?</p>