From e7154bee1afe6594c73df64889b051b6ea608458 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Fri, 13 Apr 2018 09:39:01 -0700 Subject: [PATCH] Remove the rest of the uses of Number.tryParse() (#16568) --- dev/bots/analyze-sample-code.dart | 6 ++++-- packages/flutter_tools/lib/src/commands/fuchsia_reload.dart | 3 ++- .../lib/src/fuchsia_remote_connection.dart | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dev/bots/analyze-sample-code.dart b/dev/bots/analyze-sample-code.dart index c27adb50aa0..cc1a7f42e10 100644 --- a/dev/bots/analyze-sample-code.dart +++ b/dev/bots/analyze-sample-code.dart @@ -238,11 +238,13 @@ dependencies: throw 'failed to parse error message: $error'; } final String column = error.substring(colon2 + kColon.length, bullet2); - final int lineNumber = int.tryParse(line, radix: 10); + // ignore: deprecated_member_use + final int lineNumber = int.parse(line, radix: 10, onError: (String source) => throw 'failed to parse error message: $error'); + // ignore: deprecated_member_use + final int columnNumber = int.parse(column, radix: 10, onError: (String source) => throw 'failed to parse error message: $error'); if (lineNumber == null) { throw 'failed to parse error message: $error'; } - final int columnNumber = int.tryParse(column, radix: 10); if (columnNumber == null) { throw 'failed to parse error message: $error'; } diff --git a/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart b/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart index 88507820762..c5099e46d60 100644 --- a/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart +++ b/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart @@ -384,7 +384,8 @@ class FuchsiaReloadCommand extends FlutterCommand { final int lastSpace = trimmed.lastIndexOf(' '); final String lastWord = trimmed.substring(lastSpace + 1); if ((lastWord != '.') && (lastWord != '..')) { - final int value = int.tryParse(lastWord); + // ignore: deprecated_member_use + final int value = int.parse(lastWord, onError: (_) => null); if (value != null) ports.add(value); } diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart b/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart index 195321a37c6..25478889c58 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart @@ -197,7 +197,8 @@ class FuchsiaRemoteConnection { final int lastSpace = trimmed.lastIndexOf(' '); final String lastWord = trimmed.substring(lastSpace + 1); if ((lastWord != '.') && (lastWord != '..')) { - final int value = int.tryParse(lastWord); + // ignore: deprecated_member_use + final int value = int.parse(lastWord, onError: (_) => null); if (value != null) { ports.add(value); }