From 4614e93cac95140f430d1b5a63d28325c7ca1245 Mon Sep 17 00:00:00 2001 From: ENDOH takanao Date: Tue, 10 Mar 2015 07:52:17 +0800 Subject: [PATCH] fix NoSuchMethodError in filter I got errors when using `filter` for objects that is nullable. I seem to be no substantial problem. However, I want to suppress unwanted errors. ``` The null object does not have a method 'toList'. NoSuchMethodError: method not found: 'toList' Receiver: null Arguments: [growable: false] STACKTRACE: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:45) #1 Filter.call (package:angular/formatter/filter.dart:193:26) ... ``` --- lib/formatter/filter.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/formatter/filter.dart b/lib/formatter/filter.dart index 5cc8fe503..a5a55e2a3 100644 --- a/lib/formatter/filter.dart +++ b/lib/formatter/filter.dart @@ -189,6 +189,9 @@ class Filter implements Function { } List call(List items, var expression, [var comparator]) { + if (items == null) { + return const []; + } if (expression == null) { return items.toList(growable: false); // Missing expression → passthrough. } else if (expression is! Map && expression is! Function &&