Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Null exception thrown in changeNotifier after it creates the object which should not make it null #69

Open
DartBot opened this issue Jun 5, 2015 · 2 comments
Labels

Comments

@DartBot
Copy link

DartBot commented Jun 5, 2015

Originally opened as dart-lang/sdk#20536

This issue was originally filed by [email protected]


What steps will reproduce the problem?

  1. Execute code that invokes ChangeNotifier.changes
  2. In certain cases, the following exception is produced:

The null object does not have a getter 'stream'.

NoSuchMethodError: method not found: 'stream'
Receiver: null
Arguments: []

STACKTRACE:

­0 Object.noSuchMethod (dart:core-patch/object_patch.dart:45)

­1 ChangeNotifier.changes (package:observe/src/change_notifier.dart:29:21)

For reference, line 24-30 from change_notifier.dart:

  Stream<List<ChangeRecord>> get changes {
    if (_changes == null) {
      _changes = new StreamController.broadcast(sync: true,
          onListen: observed, onCancel: unobserved);
    }
    return _changes.stream;
  }

What is the expected output? What do you see instead?
_changes should never be null, so no exception should be thrown.

What version of the product are you using?
Dartium Version 37.0.2062.0 (287872) (64-bit)

On what operating system?
Linux

What browser (if applicable)?
Dartium Version 37.0.2062.0 (287872) (64-bit)

Please provide any additional information below.

C1

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/8631949?v=3" align="left" width="48" height="48"hspace="10"> Comment by floitschG


Added Area-Pkg, Pkg-Observe, Triaged labels.

@DartBot DartBot added the bug label Jun 5, 2015
@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/984921?v=3" align="left" width="48" height="48"hspace="10"> Comment by jakemac53


Hmm, this is really weird. Is it possible for you to attach a repro of this?

Technically, StreamController.broadcast is a factory method and as such could return a null I believe (although this would be bad practice imo since factories and constructors appear identical in dart). However in reality it looks like it does not do that...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

1 participant