findCalloutPoints function
List<FluentCustomizedCalloutDataPoint> ?
findCalloutPoints(
- List<
FluentCustomizedCalloutData> data, - Object? x, {
- required bool isXAxisDate,
The callout rows at x, or null when there are none.
Ports findCalloutPoints (utilities.ts:2560-2577), including the null
guard at :2564. Upstream returns { x, values }, but its x is the
argument the caller already holds, so the port returns the rows alone.
Recorded divergence.
isXAxisDate is a port addition. Upstream's scale inverts to a Date, so
its x instanceof Date test is enough; a Flutter time scale inverts to a
double, so a caller on a date axis may hold epoch milliseconds. When
isXAxisDate is true a numeric x is read as milliseconds since epoch and
finds the same entry a DateTime would.
Implementation
List<FluentCustomizedCalloutDataPoint>? findCalloutPoints(
List<FluentCustomizedCalloutData> data,
Object? x, {
required bool isXAxisDate,
}) {
if (x == null) {
return null;
}
// utilities.ts:2568.
final key = switch (x) {
final DateTime value => value.millisecondsSinceEpoch,
final num value when isXAxisDate => value.toInt(),
_ => x,
};
for (final entry in data) {
final entryX = entry.x;
final entryKey = entryX is DateTime
? entryX.millisecondsSinceEpoch
: entryX;
if (entryKey == key) {
return entry.values;
}
}
// utilities.ts:2569-2571.
return null;
}