Reputation: 187
When I load a component using 'filter', the 'call' method is being run before the 'items' parameter is being set. So I am getting repeating errors from line 200. Eventually, 'items' is sent and the 'call' method runs without error.
The null object does not have a method 'where'.
NoSuchMethodError: method not found: 'where'
Receiver: null
Arguments: [Closure: (dynamic) => dynamic]
STACKTRACE:
#0 Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
#1 Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#2 Filter.call (package:angular/formatter/filter.dart:200:26)
This is the first time I have implemented filter using AngularDart, and this is happening in both components I've tried. There's nothing special in my template:
<tr ng-repeat="appSession in appSessions | orderBy: orderByList | filter: filterObject">
The appSessions list is either set by an attribute or if not provided, in attach method. In this case, it is being set by the attribute.
@NgOneWay("app-sessions") List<AppSessionModel> appSessions;
@NgOneWay("mobile-user-id") int mobileUserID;
void attach() {
if (appSessions == null) {
if (mobileUserID != null) {
appSessionManager.getForUser(mobileUserID).then((sessions) {
appSessions = sessions;
});
} else if (!fromUserTable) {
appSessionManager.getOpen().then((sessions) {
appSessions = sessions;
});
}
}
}
Has anyone else experienced this? Is there a timing bug here?
Thanks, Sam
Upvotes: 1
Views: 190
Reputation: 187
After more debugging, I confirmed that my list was never null in the 'attach' method, and I confirmed that Filter.call was running after the 'attach' method. It turns out that the problem related to the 'orderBy' in the template.
I had this:
<tr ng-repeat="appSession in appSessions | orderBy: orderByList | filter: filterObject">
If I switch 'orderBy' and 'filter', then no more Filter.call error:
<tr ng-repeat="appSession in appSessions | filter: filterObject | orderBy: orderByList">
I debugged OrderBy.call, but it is not returning 'items' as null, so the problem seems to be somewhere between OrderBy and Filter, but I don't know enough about AngularDart to know what that might be.
Upvotes: 1
Reputation: 657018
You could just initialize the field with an empty list
List<AppSessionModel> appSessions = [];
Upvotes: 0