Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:core
  3. bool
  4. parse static method
parse
description

parse static method

  1. @Since.new("3.0")
boolparse(
  1. Stringsource, {
  2. boolcaseSensitive =true,
})

Parsessource as an, optionally case-insensitive, boolean literal.

IfcaseSensitive istrue, which is the default,the only accepted inputs are the strings"true" and"false",which returns the resultstrue andfalse respectively.

IfcaseSensitive isfalse, any combination of upper and lower caseASCII letters in the words"true" and"false" are accepted,as if the input was first lower-cased.

Throws aFormatException if thesource string does not containa valid boolean literal.

Rather than throwing and immediately catching theFormatException,instead usetryParse to handle a potential parsing error.

Example:

print(bool.parse('true')); // trueprint(bool.parse('false')); // falseprint(bool.parse('TRUE')); // throws FormatExceptionprint(bool.parse('TRUE', caseSensitive: false)); // trueprint(bool.parse('FALSE', caseSensitive: false)); // falseprint(bool.parse('NO')); // throws FormatExceptionprint(bool.parse('YES')); // throws FormatExceptionprint(bool.parse('0')); // throws FormatExceptionprint(bool.parse('1')); // throws FormatException

Implementation

@Since("3.0")external static bool parse(String source, {bool caseSensitive = true});
  1. Dart
  2. dart:core
  3. bool
  4. parse static method
bool class

[8]ページ先頭

©2009-2025 Movatter.jp