From 60b87b1857bfe03e473647510cabe47aaf4efae5 Mon Sep 17 00:00:00 2001 From: Kyle Lee <59222981+kylelmh@users.noreply.github.com> Date: Fri, 6 Dec 2024 19:12:32 +0900 Subject: [PATCH] migrated dart to v3 (#639) Co-authored-by: Doug Rinckes --- dart/lib/src/open_location_code.dart | 7 ++++++- dart/pubspec.yaml | 4 ++-- dart/test/encode_test.dart | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dart/lib/src/open_location_code.dart b/dart/lib/src/open_location_code.dart index b8af9cf7..10ecc5ac 100644 --- a/dart/lib/src/open_location_code.dart +++ b/dart/lib/src/open_location_code.dart @@ -134,7 +134,12 @@ bool isValid(String code) { if (padMatch.length != 1) { return false; } - var matchLength = padMatch.first.group(0).length; + var matches = padMatch.first.group(0); + if (matches == null) { + return false; + } + + var matchLength = matches.length; if (matchLength.isOdd || matchLength > separatorPosition - 2) { return false; } diff --git a/dart/pubspec.yaml b/dart/pubspec.yaml index 67c6670d..3fe399a8 100644 --- a/dart/pubspec.yaml +++ b/dart/pubspec.yaml @@ -3,6 +3,6 @@ description: Open Location Codes are short, generated codes that can be used lik version: 0.0.1 homepage: http://openlocationcode.com/ environment: - sdk: '<3.0.0' + sdk: '^2.19.6' dev_dependencies: - test: '>=0.12.0' + test: ^1.24.3 diff --git a/dart/test/encode_test.dart b/dart/test/encode_test.dart index bc71fcfc..154b313d 100644 --- a/dart/test/encode_test.dart +++ b/dart/test/encode_test.dart @@ -23,7 +23,7 @@ void checkEncodeDecode(String csvLine) { var elements = csvLine.split(','); num lat = double.parse(elements[0]); num lng = double.parse(elements[1]); - num len = int.parse(elements[2]); + int len = int.parse(elements[2]); var want = elements[3]; var got = olc.encode(lat, lng, codeLength: len); expect(got, equals(want));