I'm successfully getting my JSON response in cosole. Trying to display it in table format using DataTable
in flutter.
I tried to use this package but it only accepting JSON array list format.But my JSON is not in Array List.
My JSON response simply a <Map>
What syntax I should use to display it in table?
{
"EncPartnerId": "LEuT1eIlpLEMAAkZme3wpQ==",
"EncTestId": "U4exk+vfMGrn7cjNUa/PBw==",
"Fee": "100",
"DiscountedFee": "80",
"BookingFee": "50"
}
My API function:
Future<void> GetTestFee() async {
var jsonResponse;
if (encTestId.isNotEmpty) {
var response = await http.post(
Uri.parse("http://medbo.digitalicon.in/api/medboapi/GetTestFee"),
body: ({
'EncPartnerId': "LEuT1eIlpLEMAAkZme3wpQ==",
'EncTestId': "U4exk+vfMGrn7cjNUa/PBw==",
}));
if (response.statusCode == 200) {
print("Correct");
print(response.body);
jsonResponse = json.decode(response.body.toString());
print(jsonResponse);
//Navigator.push(context,MaterialPageRoute(builder: (context) => DieticianAfterDateSelectPage( rresponse: DieticianEncBookingIdModel.fromJson(jsonResponse),)));
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text("Test Added")));
} else {
throw Exception("Faild to fetch");
}
} else {
throw Exception("Faild to fetch");
}
}
Then insted of Dummy data how can I display my JSON response data? Should I use ListView.builder?
Container(
child: Column(
children:[
DataTable(
columns: <DataColumn>[
DataColumn(label: Text("Test Name")),
DataColumn(label: Text("Fee")),
DataColumn(label: Text("Discounted Fee")),
],
rows: <DataRow>[
DataRow(
cells: <DataCell>[
DataCell(Text("jjj")),
DataCell(Text("jsjf")),
DataCell(Text("jsjf")),
]
)
]
)
]
)
)