Remove usage of deprecated `onError` argument to `int.parse` and `double.parse`. (#43)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fd41fdb..ce42469 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
## 2.1.14
+* Remove use of deprecated features.
* Updated SDK version to 2.0.0-dev.17.0
## 2.1.13
diff --git a/lib/src/loader.dart b/lib/src/loader.dart
index d00fc2c..956b17c 100644
--- a/lib/src/loader.dart
+++ b/lib/src/loader.dart
@@ -302,12 +302,12 @@
// Hexadecimal or octal integers.
if (allowInt && firstChar == $0) {
- // int.parse supports 0x natively.
- if (secondChar == $x) return int.parse(contents, onError: (_) => null);
+ // int.tryParse supports 0x natively.
+ if (secondChar == $x) return int.tryParse(contents);
if (secondChar == $o) {
var afterRadix = contents.substring(2);
- return int.parse(afterRadix, radix: 8, onError: (_) => null);
+ return int.tryParse(afterRadix, radix: 8);
}
}
@@ -321,10 +321,10 @@
if (allowInt) {
// Pass "radix: 10" explicitly to ensure that "-0x10", which is valid
// Dart but invalid YAML, doesn't get parsed.
- result = int.parse(contents, radix: 10, onError: (_) => null);
+ result = int.tryParse(contents, radix: 10);
}
- if (allowFloat) result ??= double.parse(contents, (_) => null);
+ if (allowFloat) result ??= double.tryParse(contents);
return result;
}
@@ -348,7 +348,7 @@
}
}
- return double.parse(contents, (_) => null);
+ return double.tryParse(contents);
}
if (length == 4 && firstChar == $dot) {
diff --git a/pubspec.yaml b/pubspec.yaml
index b60d7cc..8f520c5 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -4,7 +4,7 @@
homepage: https://github.com/dart-lang/yaml
description: A parser for YAML.
environment:
- sdk: '>=2.0.0-dev.17.0 <2.0.0'
+ sdk: '>=2.0.0-dev.49.0 <2.0.0'
dependencies:
charcode: "^1.1.0"
collection: ">=1.1.0 <2.0.0"