Статический метод 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.19.6/dart-core/DateTime/tryParse.html