File tree Expand file tree Collapse file tree 3 files changed +14
-11
lines changed Expand file tree Collapse file tree 3 files changed +14
-11
lines changed Original file line number Diff line number Diff line change 11org.gradle.jvmargs =-Xmx1536M
2- org.gradle.java.home =C:\\Program Files\\Java\\jdk1.8.0_144
3- android.enableR8 =true
42android.useAndroidX =true
53android.enableJetifier =true
Original file line number Diff line number Diff line change 11[
22 {
3- "year " : " Jan" ,
3+ "month " : " Jan" ,
44 "sales" : 35.0
55 },
66 {
7- "year " : " Feb" ,
7+ "month " : " Feb" ,
88 "sales" : 28.0
99 },
1010 {
11- "year " : " Mar" ,
11+ "month " : " Mar" ,
1212 "sales" : 34.0
1313 },
1414 {
15- "year " : " Apr" ,
15+ "month " : " Apr" ,
1616 "sales" : 32.0
1717 },
1818 {
19- "year " : " May" ,
19+ "month " : " May" ,
2020 "sales" : 40.0
2121 }
2222]
Original file line number Diff line number Diff line change @@ -30,13 +30,17 @@ class _MyHomePageState extends State<MyHomePage> {
3030 List <SalesData > chartData = [];
3131
3232 Future loadSalesData () async {
33- String jsonString = await rootBundle. loadString ( 'assets/data.json' );
34- final dynamic jsonResponse = json.decode (jsonString);
33+ String jsonString = await getJsonFromAssets ( );
34+ final jsonResponse = json.decode (jsonString);
3535 for (Map <String , dynamic > i in jsonResponse) {
3636 chartData.add (SalesData .fromJson (i));
3737 }
3838 }
3939
40+ Future <String > getJsonFromAssets () async {
41+ return await rootBundle.loadString ('assets/data.json' );
42+ }
43+
4044 @override
4145 void initState () {
4246 super .initState ();
@@ -50,9 +54,10 @@ class _MyHomePageState extends State<MyHomePage> {
5054 ),
5155 body: Center (
5256 child: FutureBuilder (
53- future: loadSalesData (),
57+ future: getJsonFromAssets (),
5458 builder: (context, snapshot) {
55- if (chartData.isNotEmpty) {
59+ loadSalesData ();
60+ if (snapshot.hasData) {
5661 return SfCartesianChart (
5762 primaryXAxis: CategoryAxis (),
5863 // Chart title
You can’t perform that action at this time.
0 commit comments