question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

_alreayCompletedSteps where was called on null

See original GitHub issue

Just tried upgrading from 0.10.0 to 0.12.0 and receiving this exception:

[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method 'where' was called on null.
Receiver: null                                                          
Tried calling: where(Closure: (String) => bool)                         
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)    
#1      Bloc._alreayCompletedSteps (package:feature_discovery/src/foundation/bloc.dart:159:10)
<asynchronous suspension>                                               
#2      Bloc.discoverFeatures (package:feature_discovery/src/foundation/bloc.dart:111:28)
#3      FeatureDiscovery.discoverFeatures (package:feature_discovery/src/foundation/feature_discovery.dart:32:24)
#4      _HomeScreenState.initState.<anonymous closure> (package:kozzeted/screens/home_screen.dart:65:24)
#5      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1113:15)
#6      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1060:9)
#7      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:968:5)
#8      _rootRun (dart:async/zone.dart:1184:13)                         
#9     <…>  

It appears that _alreayCompletedSteps is trying to reference _steps before it has been initialized.

Oh, and I presume _alreayCompletedSteps should be _alreadyCompletedSteps .

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
narcodicocommented, Oct 25, 2020

Your method

void discoverFeatures(Iterable<String> steps) async

should actually return a Future<void>. Due to asynchronous matter of the code setting a local variable and working with it is problematic. You’d be better of doing something like:

_stepsToIgnore = await _alreadyCompletedSteps(steps);
    _stepsController.add(_steps.where((s) => !_stepsToIgnore.contains(s)).toList());

Keeping local state in a bloc is not recommended, since everything should be handled through Sinks and Streams. You could handle your steps with the help of a StreamController.

1reaction
narcodicocommented, Oct 25, 2020

Hey @ayalma, this doesn’t seem fixed. I’m getting the exact same error with 0.12.1.

I/flutter (17796): NoSuchMethodError: The method 'where' was called on null.
I/flutter (17796): Receiver: null
I/flutter (17796): Tried calling: where(Closure: (String) => bool)
I/flutter (17796):
I/flutter (17796): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
I/flutter (17796): #1      Bloc._alreadyCompletedSteps
package:feature_discovery/…/foundation/bloc.dart:160
I/flutter (17796): <asynchronous suspension>
I/flutter (17796): #2      Bloc.discoverFeatures
package:feature_discovery/…/foundation/bloc.dart:112
I/flutter (17796): #3      FeatureDiscovery.discoverFeatures
package:feature_discovery/…/foundation/feature_discovery.dart:32
I/flutter (17796): #4      _HomeState.initState.<anonymous closure>.<anonymous closure>
package:dotasuperstar/…/view/home_view.dart:55
I/flutter (17796): #5      _rootRun (dart:async/zone.dart:1182:47)
I/flutter (17796): #6      _CustomZone.run (dart:async/zone.dart:1093:19)
I/flutter (17796): #7      _CustomZone.runGuarded (dart:async/zone.dart:997:7)
I/flutter (17796): #8      _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
I/flutter (17796): #9      _rootRun (dart:async/zone.dart:1190:13)
I/flutter (17796): #10     _CustomZone.run (dart:async/zone.dart:1093:19)
I/flutter (17796): #11     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
I/flutter (17796): #12     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037

Read more comments on GitHub >

github_iconTop Results From Across the Web

The method '[]' was called on null. Receiver: null Tried calling
First of all you should try putting some print statements (or better use debugger) near the line where you retrieve the data. if...
Read more >
NoSuchMethodError: The Method was Called on null — Flutter
Learn what causes "Flutter Android Gradle tool issue: NoSuchMethodError: The method 'reinitialize' was called on null."
Read more >
NoSuchMethodError: The method 'where' was called on null ...
Hi there, I am getting the following error printed out for every file in my project when running flutter pub run build_runner build...
Read more >
The method 'contains' was called on null. Receiver - Reddit
I am new to flutter, and am using an api to keep people updated on the latest technology news, but am getting this...
Read more >
Understanding null safety - Dart
If you run this Dart program without null safety, it throws a NoSuchMethodError exception on the call to .length . The null value...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found