@@ -309,7 +309,7 @@ class IndicatorsModel {
309309 values: values,
310310 ));
311311 } else if (item is AlligatorSeries ) {
312- //TODO : enable offset after fixing in the flutter charts
312+ //TO DO : enable offset after fixing in the flutter charts
313313 tooltipContent.add (JsIndicatorTooltip (
314314 name: AlligatorIndicatorConfig .name,
315315 values: < String ? > [
@@ -368,6 +368,16 @@ class IndicatorsModel {
368368 double y,
369369 int bottomIndicatorIndex,
370370 ) {
371+ /// Called to get epoch from x position
372+ int ? _getClosestEpoch (int ? x, int granularity) {
373+ try {
374+ return getClosestEpoch? .call (x, granularity);
375+ // ignore: avoid_catches_without_on_clauses
376+ } catch (_) {
377+ return null ;
378+ }
379+ }
380+
371381 int configIndex = 0 ;
372382 Series ? bottomItemIndicator;
373383 final List <Series > sortedSeriesList = < Series > [...seriesList];
@@ -388,9 +398,11 @@ class IndicatorsModel {
388398
389399 final Offset target = Offset (x, y);
390400 final int ? epoch =
391- getClosestEpoch ? . call (controller.getEpochFromX (x), granularity);
401+ _getClosestEpoch (controller.getEpochFromX (x), granularity);
392402
393- if (bottomItemIndicator != null && bottomIndicatorIndex != null ) {
403+ if (bottomItemIndicator != null &&
404+ bottomIndicatorIndex > - 1 &&
405+ epoch != null ) {
394406 if (bottomItemIndicator is AwesomeOscillatorSeries ) {
395407 final List <Tick > aoEntries = bottomItemIndicator.entries ?? < Tick > [];
396408
@@ -816,11 +828,11 @@ class IndicatorsModel {
816828 }
817829 }
818830 } else if (item is AlligatorSeries ) {
819- final List <Tick > teethEntries = item.teethSeries! .entries ?? < Tick > [];
831+ final List <Tick > teethEntries = item.teethSeries? .entries ?? < Tick > [];
820832
821- final List <Tick > jawEntries = item.jawSeries! .entries ?? < Tick > [];
833+ final List <Tick > jawEntries = item.jawSeries? .entries ?? < Tick > [];
822834
823- final List <Tick > lipEntries = item.lipsSeries! .entries ?? < Tick > [];
835+ final List <Tick > lipEntries = item.lipsSeries? .entries ?? < Tick > [];
824836
825837 if (isPointOnIndicator (
826838 teethEntries,
@@ -864,7 +876,7 @@ class IndicatorsModel {
864876 if (index != null ) {
865877 final int quoteIndex = index - offset;
866878
867- if (quoteIndex <= entries.length - 1 ) {
879+ if (quoteIndex <= entries.length - 1 && quoteIndex > 0 ) {
868880 final Tick prevIndex = entries[quoteIndex - 1 ];
869881 final Tick currIndex = entries[quoteIndex];
870882
0 commit comments