Fixed null safety
This commit is contained in:
parent
3dadedaf20
commit
9c2f0cfa28
1 changed files with 12 additions and 5 deletions
|
@ -190,11 +190,18 @@ abstract class Parser<T> {
|
||||||
Parser<List<T>> separatedBy(Parser other) {
|
Parser<List<T>> separatedBy(Parser other) {
|
||||||
var suffix = other.then(this).index(1).cast<T>();
|
var suffix = other.then(this).index(1).cast<T>();
|
||||||
return this.then(suffix.star()).map((r) {
|
return this.then(suffix.star()).map((r) {
|
||||||
|
List<dynamic>? v = r.value;
|
||||||
|
if (v != null) {
|
||||||
var preceding =
|
var preceding =
|
||||||
r.value!.isEmpty ? [] : (r.value![0] == null ? [] : [r.value![0]]);
|
v.isEmpty ? [] : (r.value?[0] == null ? [] : [r.value?[0]]);
|
||||||
var out = List<T>.from(preceding);
|
var out = List<T>.from(preceding);
|
||||||
if (r.value![1] != null) out.addAll(r.value![1] as List<T>);
|
if (r.value?[1] != null) {
|
||||||
|
out.addAll(r.value?[1] as List<T>);
|
||||||
|
}
|
||||||
return out;
|
return out;
|
||||||
|
} else {
|
||||||
|
return List<T>.empty(growable: true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue