title: how to return one item and list of items in flutter
body: <p>I built an app which is used to return user information from the server and the information maybe contain item or list of items 
  my problem is that when I define the variable as a list it returns list of items but it makes an error when I want to return one item only and when I define the variable as a map it returns one item but it makes error when I return a list 
  how can I solve this ?</p>
  
  <p>P.S. this is my code </p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:idb/pages/aboutus.dart';
  import 'package:idb/pages/logout.dart';
  import 'package:idb/utilities/cardinfo.dart';
  import 'package:idb/utilities/getTokenParameter.dart';
  import 'package:date_range_picker/date_range_picker.dart' as DateRagePicker;
  import 'package:idb/utilities/postRequest.dart';
  
  String userid = '0000';
  
  Future getUsername() async {
    var tokeninfo = await parseJwt();
    userid = tokeninfo['117115101114105100'];
  }
  
  class HomePage extends StatefulWidget {
    @override
    State&lt;StatefulWidget&gt; createState() {
      return HomePageState();
    }
  }
  
  class HomePageState extends State&lt;HomePage&gt; {
    List item;
  
    cardfoo() async {
      Map&lt;String, dynamic&gt; user = await getCards(userid);
  
      item = user['ResponseData']['data']['ROW'];
  
      if (mounted) {
        setState(() {
          item = user['ResponseData']['data']['ROW'];
  
          print('item: ${item}');
        });
      }
      return 'success';
    }
  
    getTransactions(
        String cardLast4digits, String dateFrom, String dateTo) async {
      var tokeninfo = await parseJwt();
      print(tokeninfo);
      print(cardLast4digits);
  
      String userid = tokeninfo['117115101114105100'];
      String username = tokeninfo['11711510111411097109101'];
      String url =
          'http://192.168.128.130:';
  
      final Map&lt;String, dynamic&gt; authData = {
        'Userid': userid,
        'Username': username,
        'Last4Digit': cardLast4digits,
        'DateFrom': dateFrom,
        'DateTo': dateTo,
      };
  
      print('befor post: ${authData}');
  
      Map&lt;String, dynamic&gt; responseData = await post(url, authData);
  
      print(responseData);
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
          appBar: AppBar(
            title: Text("Home"),
          ),
          body: item == null
              ? Center(
                  child: CircularProgressIndicator(),
                )
              : ListView.builder(
                  itemCount: item == null ? 0 : item.length,
                  scrollDirection: Axis.vertical,
                  shrinkWrap: true,
                  itemBuilder: (BuildContext context, int index) {
                    return new Column(
                      children: &lt;Widget&gt;[
                        Card(
                          margin: EdgeInsets.only(
                            top: 20,
                            left: 15,
                            right: 15,
                          ),
                          shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(15.0),
                          ),
                          color: Colors.white70,
                          child: new Column(
                            children: &lt;Widget&gt;[
  
                              new Padding(
                                  padding: new EdgeInsets.all(7.0),
                                  child: new Column(
                                    children: &lt;Widget&gt;[
                                      new Row(children: &lt;Widget&gt;[
                                        new Padding(
                                          padding: new EdgeInsets.all(7.0),
                                          child: new Text('Embossed Name:',
                                              style: new TextStyle(
                                                  fontSize: 15.0,
                                                  color: Colors.orange)),
                                        ),
                                        new Padding(
                                          padding: new EdgeInsets.all(7.0),
                                          child: new Text(
                                              item[index]['EMBOSSED_NAME'],
                                              style:
                                                  new TextStyle(fontSize: 15.0)),
                                        ),
                                      ]),
  
  
                        SizedBox(
                          height: 10,
                        ),
                        Column(
                          children: &lt;Widget&gt;[
                            Row(
                              children: &lt;Widget&gt;[
                                FlatButton.icon(
                                  textColor: Colors.blue,
                                  icon: Icon(
                                      Icons.calendar_today), //`Icon` to display
                                  label: Text('Transctions'),
  
                                  onPressed: () async {
                                    final List&lt;DateTime&gt; picked =
                                        await DateRagePicker.showDatePicker(
                                            context: context,
                                            initialFirstDate: new DateTime.now(),
                                            initialLastDate: (new DateTime.now())
                                                .add(new Duration(days: 7)),
                                            firstDate: new DateTime(2015),
                                            lastDate: new DateTime(2020));
  
                                    if (picked != null &amp;&amp; picked.length == 2) {
  
                                      getTransactions(
                                          item[index]['CARD_NO'],
                                          picked[0].toString(),
                                          picked[1].toString());
                                    }
                                  },
                                ),
                              ],
                            ),
                          ],
                        ),
                      ],
                    );
                  },
                ));
    }
  
    @override
    void initState() {
      super.initState();
      this.cardfoo();
    }
  }
  </code></pre>
  
  <p>and the error is that </p>
  
  <blockquote>
    <p>Dart Error: Unhandled exception: type '_InternalLinkedHashMap' is not a subtype of type 'List'</p>
  </blockquote>