orWhereNotBetween method

Query orWhereNotBetween(
  1. dynamic columnName,
  2. dynamic startValue,
  3. dynamic endValue
)

Implementation

Query orWhereNotBetween(columnName, startValue, endValue) {
  if (!_lastQuery.contains('WHERE')) {
    _lastQuery += ' WHERE ';
  } else {
    _lastQuery += ' OR ';
  }

  _lastQuery += ' $columnName NOT BETWEEN ';

  final tryParse = [DateTime.tryParse(startValue), DateTime.tryParse(endValue)];
  int count = 0;
  for (var i in tryParse) {
    ++count;

    if (count == 2) {
      _lastQuery += ' AND ';
    }
    if (i != null) {
      _lastQuery += i.millisecondsSinceEpoch.toString() + ' ';
    } else {
      int? tryInt;
      if (count == 1) {
        tryInt = int.tryParse(startValue);
      } else if (count == 2) {
        tryInt = int.tryParse(endValue);
      }

      if (tryInt != null) {
        _lastQuery += tryInt.toString() + ' ';
      }
    }
  }

  return this;
}