I am trying to make a list of medicines in my mobile app. My data is in a local json file.
{
"BARKOD": 8699755640016,
"ATC KODU": "A01AA",
"ATC ADI": "Caries prophylactic agents",
"REFERANS \nE�DE�ER": "E�DE�ER",
"ESDEGERI": 2,
"ILAC ADI": "SENSORAL 250 ML SOLUSYON",
"ETKIN MADDE": "POTASYUM NITRAT + SODYUM KLORUR",
"FIRMA ADI": "DENTORAL MEDIFARMA",
"BIRIM MIKTAR": "",
"BIRIM CINSI": "",
"AMBALAJ MIKTARI": 250,
"RE�ETE": "NORMAL RE�ETE",
"KDV DAHIL PERAKENDE SATIS TL FIYATI \n1 ? =2,1166 TL": "5,69"
},
one of them is like that. I am trying to make all of these data to appear when I click on a button. My code is like below.
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:medicine_reminder/src/ui/homepage/homepage.dart';
class JsonPage extends StatefulWidget {
@override
_JsonPageState createState() => _JsonPageState();
}
class _JsonPageState extends State<JsonPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Medicine List"),
centerTitle: true,
),
body: Center(
child: FutureBuilder(
builder: (context, snapshot) {
var showData = json.decode(snapshot.data.toString());
return ListView.builder(
itemBuilder: (BuildContext context, int index) {
return ListTile(
isThreeLine: true,
title: Text(showData[index]['ILAC ADI']),
subtitle: Text(showData[index]['ETKIN MADDE']),
);
},
itemCount: showData.length,
);
},
future:
DefaultAssetBundle.of(context).loadString("assets/csvjson.json"),
),
),
floatingActionButton: Stack(
children: <Widget>[
Padding(
padding: EdgeInsets.only(right: 1),
child: Align(
heightFactor: 12.9,
alignment: Alignment.topLeft,
child: FloatingActionButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HomePage(),
));
},
child: Icon(Icons.arrow_back),
),
),
),
],
),
);
}
}
but I can not get all the fields, I am only able to get just 2 fields 'ILAC ADI' AND 'ETKIN MADDE'. How can I solve this?