INNER CODE UNIT · Dart

toBoolean

Ephenodrom/Dart-Basic-Utils · lib/src/BooleanUtils.dart:79

  static bool toBoolean(final int value) {
    return value != 0;
  }

  /// Converts a String to a Boolean.
  ///
  /// 'true', 'on', 'y', 't', 'yes'
  /// or '1' (case insensitive) will return true.
  /// 'false', 'off', 'n', 'f', 'no'
  /// or '0' (case insensitive) will return false.
  /// Otherwise, null is returned.
  ///
  /// NOTE: This method may return null and may throw a NullPointerException
  /// if unboxed to a boolean
  ///
  ///   // N.B. case is not significant
  ///   BooleanUtils.toBooleanObject(null)    = null
  ///   BooleanUtils.toBooleanObject("true")  = true

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…