title: Flutter FutureBuilder Snapshot is null but Future Does return data
body: <p>While working with Flutter for a new application client for Kanboard, I encountered the following problem. I have a FutureBuilder that should return a select dropdown menu with items but, for some reason, the Snapshot data is null, although the Future method does resolves and has data on return.</p>
  <p>Full page.dart code here: <a href="https://pastebin.com/J48nxsdZ" rel="nofollow noreferrer">https://pastebin.com/J48nxsdZ</a></p>
  <p>The block having the problem is the following:</p>
  <pre><code>Widget _columnSelect() {
  return FutureBuilder(
    future: columnProvider.getColumns(task.projectId),
    builder: (BuildContext context, AsyncSnapshot snapshot) {
      List&lt;DropdownMenuItem&lt;String&gt;&gt; columnList = [];
      if (snapshot.hasData) {
        columnList.add(DropdownMenuItem&lt;String&gt;(
            child: Text('Select Column'), value: 0.toString()));
        _columns = snapshot.data;
      } else {
        columnList.add(DropdownMenuItem&lt;String&gt;(
            child: Text('Loading..'), value: 0.toString()));
      }
      _columns.forEach((column) {
        columnList.add(DropdownMenuItem&lt;String&gt;(
            child: Container(
              child: Text(
                column.title,
              ),
            ),
            value: column.id.toString()));
      });
      return Container(
        // margin: EdgeInsets.only(left: 40.0),
        padding: EdgeInsets.symmetric(horizontal: 20.0),
        child: DropdownButtonFormField(
          icon: Padding(
            padding: const EdgeInsets.only(right: 12),
            child: Icon(Icons.view_column, color: Colors.blue),
          ),
          items: columnList,
          value: _columnId,
          decoration: InputDecoration(helperText: 'Optional'),
          onChanged: (newValue) {
            _columnId = newValue;
          },
        ),
      );
    },
  );
  }
  </code></pre>
  <p>This is a duplicate of a widget in the same form for a user dropdown select. The original widget (in the same page) is the following:</p>
  <pre><code>Widget _ownerSelect() {
  return FutureBuilder(
    future: userProvider.getUsers(),
    builder: (BuildContext context, AsyncSnapshot snapshot) {
      List&lt;DropdownMenuItem&lt;String&gt;&gt; usernameList = [];
      if (snapshot.hasData) {
        usernameList.add(DropdownMenuItem&lt;String&gt;(
            child: Text('Select Owner'), value: 0.toString()));
        _users = snapshot.data;
      } else {
        usernameList.add(DropdownMenuItem&lt;String&gt;(
            child: Text('Loading..'), value: 0.toString()));
      }
      _users.forEach((user) {
        usernameList.add(DropdownMenuItem&lt;String&gt;(
            child: Container(
              child: Text(
                user.name,
              ),
            ),
            value: user.id.toString()));
      });
      return Container(
        // margin: EdgeInsets.only(left: 40.0),
        padding: EdgeInsets.symmetric(horizontal: 20.0),
        child: DropdownButtonFormField(
          icon: Padding(
            padding: const EdgeInsets.only(right: 12),
            child: Icon(Icons.person, color: Colors.blue),
          ),
          items: usernameList,
          value: _ownerId,
          decoration: InputDecoration(helperText: 'Optional'),
          onChanged: (newValue) {
            _ownerId = newValue;
          },
        ),
      );
    },
  );
  }
  </code></pre>
  <p>For some reason, the &quot;_columnSelect&quot; AsyncSnapshot is null always, even when the Future method is working fine:</p>
  <pre><code>import 'dart:convert';
  import 'package:http/http.dart' as http;
  import 'package:kanboard/src/models/column_model.dart';
  import 'package:kanboard/src/preferences/user_preferences.dart';
  
  class ColumnProvider {
    final _prefs = new UserPreferences();
  
    Future&lt;List&lt;ColumnModel&gt;&gt; getColumns(projectId) async {
      final Map&lt;String, dynamic&gt; parameters = {
        &quot;jsonrpc&quot;: &quot;2.0&quot;,
        &quot;method&quot;: &quot;getColumns&quot;,
        &quot;id&quot;: 887036325,
        &quot;params&quot;: {&quot;project_id&quot;: projectId}
      };
  
      final credentials = &quot;${_prefs.username}:${_prefs.password}&quot;;
  
      Codec&lt;String, String&gt; stringToBase64 = utf8.fuse(base64);
  
      String encoded = stringToBase64.encode(credentials);
  
      final resp = await http.post(
        Uri.parse(_prefs.endpoint),
        headers: &lt;String, String&gt;{&quot;Authorization&quot;: &quot;Basic $encoded&quot;},
        body: json.encode(parameters),
      );
  
      final decodedData = json.decode(utf8.decode(resp.bodyBytes));
      final List&lt;ColumnModel&gt; columns = [];
  
      final List&lt;dynamic&gt; results = decodedData['result'];
  
      if (decodedData == null) return [];
  
      results.forEach((column) {
        final columnTemp = ColumnModel.fromJson(column);
        columns.add(columnTemp);
      });
      print(columns);
      return columns;
    }
  }
  </code></pre>
  <p>The output of &quot;print(columns)&quot; returns:</p>
  <pre><code>I/flutter ( 9486): [Instance of 'ColumnModel', Instance of 'ColumnModel', Instance of 'ColumnModel', Instance of 'ColumnModel']
  </code></pre>
  <p>I don't know what I'm missing here. The form has 2 users dropdown select (with the original FutureBuilder Widget) which works just fine. The Column widget with the Future Builder is the one with the &quot;null&quot; problem in snapshot.data.</p>
  <p>Thank you in advance for your time and support with this!</p>