googlecodelabs / photos-sharing

Code for the "Build a Photo Sharing app with Google Photos and Flutter" codelab
Apache License 2.0
98 stars 76 forks source link

Getting this error after clicking my google account for signin on the photo-sharing-final code. #2

Closed richardcatlin closed 5 years ago

richardcatlin commented 5 years ago

Unhandled Exception: NoSuchMethodError: The getter 'iterator' was called on null. E/flutter (10059): Receiver: null E/flutter (10059): Tried calling: iterator E/flutter (10059): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5) E/flutter (10059): #1 ExpandIterator.moveNext (dart:_internal/iterable.dart:481:51) E/flutter (10059): #2 __CompactLinkedHashSet&_HashFieldBase&_HashBase&_OperatorEqualsAndHashCode&SetMixin.addAll (dart:collection/set.dart:57:23) E/flutter (10059): #3 PhotosLibraryApiModel.updateAlbums (package:sharing_codelab/model/photos_library_api_model.dart:173:13) E/flutter (10059): E/flutter (10059): #4 PhotosLibraryApiModel.signIn (package:sharing_codelab/model/photos_library_api_model.dart:70:5) E/flutter (10059): #5 _asyncThenWrapperHelper. (dart:async-patch/async_patch.dart:77:64) E/flutter (10059): #6 _rootRunUnary (dart:async/zone.dart:1132:38) E/flutter (10059): #7 _CustomZone.runUnary (dart:async/zone.dart:1029:19) E/flutter (10059): #8 _FutureListener.handleValue (dart:async/future_impl.dart:126:18) E/flutter (10059): #9 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45) E/flutter (10059): #10 Future._propagateToListeners (dart:async/future_impl.dart:668:32) E/flutter (10059): #11 Future._completeWithValue (dart:async/future_impl.dart:483:5) E/flutter (10059): #12 Future._asyncComplete. (dart:async/future_impl.dart:513:7) E/flutter (10059): #13 _rootRun (dart:async/zone.dart:1124:13) E/flutter (10059): #14 _CustomZone.run (dart:async/zone.dart:1021:19) E/flutter (10059): #15 _CustomZone.runGuarded (dart:async/zone.dart:923:7) E/flutter (10059): #16 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23) E/flutter (10059): #17 _microtaskLoop (dart:async/schedule_microtask.dart:41:21) E/flutter (10059): #18 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5) E/flutter (10059):

jfschmakeit commented 5 years ago

This error occurs because your account does not have any (shared) albums.

The fix is to check for null when updating the albums in updateAlbums (lib/model/photos_library_api_model.dart:156). I'll submit a fix for this shortly.