title: Flutter loading data from SharedPreference before the page loads
body: <p>I pull more than one data from ListString and then separate them with a For Loop, make an object and then add it to a list and add this list to another list and DropDownList adds elements in that list. But the problem is when i trying to adding list(object list) to the other list(DropDownList list) I can't add elements.</p>
  <p>code:</p>
  <pre><code>    late String selectedValue = '';
    List&lt;String&gt; dropDownItemValue = [];
    List&lt;NotePages&gt; notePages = [];
    final List&lt;NotePages&gt; pages = [];
  
    Future&lt;NotePages?&gt; read() async {
      SharedPreferences prefs = await SharedPreferences.getInstance();
  
      var keys = prefs.getKeys();
  
      for (var key in keys) {
        var pageList = prefs.getStringList(key);
  
        if (pageList?[0] == 'page') {
          NotePages page = new NotePages(
              type: pageList![0],
              pageName: pageList[1],
              createdTime: DateTime.parse(pageList[2]));
  
          pages.add(page);
          await addInTheList();
        }
      }
    }
  
    addInTheList() {
      for (var i = 0; i &lt; pages.length; i++) {
        notePages.add(pages[i]);
        print(pages[i]);
      }
    }
  
    @override
    void initState() {
      super.initState();
  
      read();
  
      for (var i = 0; i &lt; notePages.length; i++) {
        dropDownItemValue.add(notePages[i].pageName);
      }
      dropDownItemValue.add('');
      dropDownItemValue.add('Add Page');
      print(dropDownItemValue);
      // selected value must be contain at dropDownItemValue
      selectedValue = dropDownItemValue[0];
    }
  </code></pre>
  <p><strong>When i use Then() in the initState the list adding elements to the other list i mean its working (i can see when i print the last list) but i can't open the DropDownList it acts like he has no element. Code like this:</strong></p>
  <pre><code>  @override
    void initState() {
      super.initState();
  
      read().then((_) =&gt; {
            for (var i = 0; i &lt; pages.length; i++) {notePages.add(pages[i])},
  
            for (var i = 0; i &lt; notePages.length; i++)
              {dropDownItemValue.add(notePages[i].pageName)},
            dropDownItemValue.add(''),
            dropDownItemValue.add('Add Page'),
            print(dropDownItemValue),
            // selected value must be contain at dropDownItemValue
            selectedValue = dropDownItemValue[0],
          });
    }
  </code></pre>
  <p><strong>how can i solve this?</strong></p>