0

This example shows how to pass one array to a List<FlSpot>, however, I need to pass two different arrays of doubles. I cannot figure out how to get both arrays into a single List<FlSpot> for the x and y variables of the spots.

//this holds the date information in a list of doubles
List<int> datesSec = logRecord.updatesDateEpoch.asList();
List<double> dateTimeDouble = datesSec.map((d) => d.toDouble()).toList();

//this holds units information in a list of doubles
List<double> unitsList = logRecord.updatesUnits.toList();

//This is where I need to figure out how to pass both of them to a list of FlSpot
List<FlSpot> spots = dateTimeDouble.map((e) => FlSpot(e, e)).toList();

How do I pass both the dateTimeDouble list to the x variable and the unitsList to the y variable?

Dennis Ashford
  • 872
  • 2
  • 7
  • 21

1 Answers1

0

After some time I was able to figure this out

List<FlSpot> newSpots = [for (int i = 0; i < dateTimeDouble.length; i++)
  FlSpot(dateTimeDouble[i], unitsList[i])];
Dennis Ashford
  • 872
  • 2
  • 7
  • 21