brianegan / flutter_redux

A library that connects Widgets to a Redux Store
MIT License
1.65k stars 219 forks source link

[ Discussion / Help ] Unexpected null value in converter function #212

Closed kvanry closed 3 years ago

kvanry commented 3 years ago

It appeared that 0.8.2 should have fixed this issue through this PR: https://github.com/brianegan/flutter_redux/pull/210

However, I'm running into the following error during the widget building.

======== Exception caught by widgets library =======================================================
The following ConverterError was thrown building StreamBuilder<Result?>(dirty, state: _StreamBuilderBaseState<Result?, AsyncSnapshot<Result?>>#e20a5):
Converter Function Error: Unexpected null value.

dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 236:49                    throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 518:63                nullCheck
packages/pinecone_flutter/view/shared/create/generic_view.dart 99:94  <fn>
packages/flutter_redux/flutter_redux.dart 505:29                                                [_computeLatestValue]
packages/flutter_redux/flutter_redux.dart 471:5   

When the converter function returns a null value, it still throws an error.

body: StoreConnector<AppState, Result?>(
        converter: (store) {
          if (widget.returnNull)
            return null;
          else
            return Result("success");
        },
    ...
brianegan commented 3 years ago

Hm, that's odd... we have several test cases that verify returning null from a converter is all good. If you change the function to converter: (store) => null does it still throw an error from _computeLatestValue?

kvanry commented 3 years ago

Closed, it was pulling in a cached flutter_redux.