getVerset4Note static method

dynamic getVerset4Note(
  1. String value, {
  2. int? position,
  3. int? returnType,
})

Implementation

static getVerset4Note(String value,{int? position, int? returnType}) { // (Ex. 1.001-005 = Chapitre:1, verset1:001 to verset2:005)
  String vers1 = value.toString().split('.').last; // Ex. 001-005
  //Tools.logCat('01- value::$value | vers1:$vers1');
  String vers = vers1.toString().split('-').first; // Ex. 001
  //Tools.logCat('02- value::$value | vers1:$vers');
  if( position!=null) {
    if (position == Constant.verseBegin) {
      vers = vers1.toString().split('-').first; // Ex. 001
      //Tools.logCat('03- value::$value | vers1:$vers');
    } else if (position == Constant.verseEnd) {
      vers = vers1.toString().split('-').last; // Ex. 005
      //Tools.logCat('04- value::$value | vers1:$vers');
    }
  }
  //Tools.logCat('05- value::$value | vers1:$vers');
  if(vers.length<3) {
    if( returnType == null ) {
      return int.parse('${vers}0').toString();
    }
    if( returnType == Constant.stringNew ) {
      return '${vers}0';
    }
    if( returnType == Constant.intNew ) {
      return int.parse('${vers}0').toString();
    }
  }
  //return int.parse( vers ).toString();
  if( returnType == null ) {
    return int.parse(vers).toString();
  }
  if( returnType == Constant.stringNew ) {
    return vers;
  }
  if( returnType == Constant.intNew ) {
    return int.parse(vers).toString();
  }
}