From 9c2f0cfa28dd1cad0dfaa3a10bcc32d1a559045e Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 21 Mar 2021 08:44:06 +0800 Subject: [PATCH] Fixed null safety --- .../lib/src/combinator/combinator.dart | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/combinator/lib/src/combinator/combinator.dart b/packages/combinator/lib/src/combinator/combinator.dart index e2ad9093..4c2f2ab4 100644 --- a/packages/combinator/lib/src/combinator/combinator.dart +++ b/packages/combinator/lib/src/combinator/combinator.dart @@ -190,11 +190,18 @@ abstract class Parser { Parser> separatedBy(Parser other) { var suffix = other.then(this).index(1).cast(); return this.then(suffix.star()).map((r) { - var preceding = - r.value!.isEmpty ? [] : (r.value![0] == null ? [] : [r.value![0]]); - var out = List.from(preceding); - if (r.value![1] != null) out.addAll(r.value![1] as List); - return out; + List? v = r.value; + if (v != null) { + var preceding = + v.isEmpty ? [] : (r.value?[0] == null ? [] : [r.value?[0]]); + var out = List.from(preceding); + if (r.value?[1] != null) { + out.addAll(r.value?[1] as List); + } + return out; + } else { + return List.empty(growable: true); + } }); }