splitNumber method

  1. @override
List<SegmentModel> splitNumber(
  1. int number
)
override

Implementation

@override
List<SegmentModel> splitNumber(int number) {
  var separatedNumbersList = number.toString().split("");
  List<SegmentModel> segments = [];
  var numberString = '';
  for ( int i = separatedNumbersList.length - 1 ; i >= 0 ; i-- ) {
    numberString = separatedNumbersList[i] + numberString;
    if (numberString.length == 3 || i == 0) {
      var segment = _getSegmentForNumber( numberString ,  segments.length );
      segments.insert( 0 , segment );
      numberString = '';
    }
  }
  return segments.toList();
}