Search code examples
flutterrestdartfl-chart

use api response in FlSpot() instead of numbers flutter


I'm trying to draw a line graph from API responses in flutter with fl_chart. In this section;

spots: [
                                                      const FlSpot(0, 1.4),
                                                      const FlSpot(4, 1.5),
                                                      const FlSpot(8, 1.6),
                                                    ],
enter image description here instead of numbers, I want to use my api responses :

  final String? sondeger;
  final String? mindeger;
  final String? maxdeger;




  const StocksDetailScreen({
    Key? key,
     this.sondeger,
     this.mindeger,
     this.maxdeger,



  }) : super(key: key);

How can I use my API responses instead of numbers?


Solution

  • Just removed const :

    spots: [
                                                          FlSpot(0, widget.min!),
                                                          FlSpot(4, widget.max!),
                                                          FlSpot(8, widget.son!),
                                                        ],