Метод tryParse
- String formattedString
Создаёт новый экземпляр DateTime на основе formattedString.
Действует аналогично parse, за исключением того, что эта функция возвращает null, тогда как parse бросит исключение FormatException.
Реализация
static DateTime? tryParse(String formattedString) {
// TODO: Optimize to avoid throwing.
try {
return parse(formattedString);
} on FormatException {
return null;
}
}
© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-core/DateTime/tryParse.html