title: Dynamically generate widgets in Flutter
body: <p>I am trying to dynamically generate a set of widgets based on a particular condition. In this case I am trying to generate a list of RadioTiles </p>
  
  <p>This is how I am trying to generate </p>
  
  <pre><code>  List _listings = new List();
  
    Widget _getListings() {
      // TODO this will accept json objects in order to display the data
      List listings = new List();
      int i = 0;
      for (i = 0; i &lt; 5; i++) {
        listings.add(
          new RadioListTile&lt;SingingCharacter&gt;(
            title: const Text('Lafayette'),
            value: SingingCharacter.lafayette,
            groupValue: _character,
            onChanged: (SingingCharacter value) {
              setState(() {
                _character = value;
              });
            },
          ),
        );
      }
  //     return listings;
    }
  </code></pre>
  
  <p>and I am trying to display this within a stateful widget like this :</p>
  
  <pre><code> return new SafeArea(
          child: Column(children: &lt;Widget&gt;[
        new Padding(
          padding: const EdgeInsets.all(20.0),
          child: new Text(
            "Verify and Select a Single Listing?",
            style: _textStyle,
          ),
        ),
        ListView(
          shrinkWrap: true,
          padding: const EdgeInsets.all(20.0),
          children: &lt;Widget&gt;[
            _getListings(),
          ],
        ),
      ]));
  </code></pre>
  
  <p>The issue is that the value of listings is null due to which I am unable to display any widgets on the screen. </p>
  
  <p>Any insights would be useful. </p>
  
  <p>Thanks,</p>
  
  <p>Edit :</p>
  
  <p>If I do try to return a list this is what I see: 
  <a href="https://i.stack.imgur.com/DA0JN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DA0JN.png" alt="enter image description here"></a></p>
  
  <p>I am not sure if this is the best way to dynamically create widgets.</p>