Home > Mobile >  How do I display my HTTP response in a list view flutter/dart
How do I display my HTTP response in a list view flutter/dart

Time:07-18

How do I display my response which is currently separated by commas in like a list view and preferably to do so in another page?

This is my code :

var response = await http.get(
        Uri.parse(
            'http://192.168.1.8:8080/HongLeong/MENU_REQUEST.do?_dc=1657717579436&table_id=25018&id_MenuAction=3&reset_context=1&ViewType=MENU_REQUEST&gui_open_popup=1&id_Window=5&activeWindowId=mw_5&noOrigUserDate=true&LocalDate=20220713&LocalTime=21061900&TimeZone=Asia/Shanghai&UserDate=0&UserTime=0&server_name=OPRISK_DATACOLLECTOR&key_id_list=&cell_context_id=0&id_Desktop=100237&operation_key=1000007&operation_sub_num=-1&is_json=1&is_popup=0&is_search_window=0&ccsfw_conf_by_user=0&is_batch=0&previousToken=1657717554097&historyToken=1657717579434&historyUrl=1'),
        headers: {HttpHeaders.cookieHeader: cookies},
      );

      ResponseModel responseModel = ResponseModel.fromJson(jsonDecode(response.body));

      var message = responseModel.response.genericListAnswer.listNode.map((x) => x.toJson()['field'][0]['field_value']).toList();

      print(message);

      Navigator.push(context,
          MaterialPageRoute(builder: (context) => const DashboardPage()));

and This is my response :

[There are 6 Users currently in the status S030 - Approved, There are 6 Users currently in the status S030 - Approved, There are 1 Users currently in the status S020 - Submit, There are 1 Users currently in the status S020 - Submit, There are 2 Risk Department currently in the status 30 - New, There are 2 Risk Department currently in the status 30 - New, There are 2 SA Department currently in the status 50 - New, There are 2 SA Department currently in the status 50 - New, There are 2 SA Department currently in the status 50 - New, There are 2 SA Department currently in the status 50 - New, There are 1 Loss Event currently in the status LE110 - Pending Approval, 473]

CodePudding user response:

ListView.builder(
 itemCount:message.length,
 itemBuilder:(context,index){
  return Text(message[index]);
  }

this is how you can show the data is listview

  • Related