Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Exception: Null check operator used on a null value #478

Closed
1 of 2 tasks
poqueque opened this issue Jun 17, 2021 · 4 comments
Closed
1 of 2 tasks

Unhandled Exception: Null check operator used on a null value #478

poqueque opened this issue Jun 17, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@poqueque
Copy link

We are receving the following error from the SDK when starting the app.

Unhandled Exception: Null check operator used on a null value

As a consequence (I guess), when calling connectUser, we receive an error

E/flutter (21157): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Exception: Already connecting
E/flutter (21157): #0 StreamChatClient.connect (package:stream_chat/src/client.dart:512:7)
E/flutter (21157): #1 StreamChatClient.connectUser (package:stream_chat/src/client.dart:434:12)
E/flutter (21157): #2 ChatConnection.connect (package:clarity_alarm/model/chat/chat_connection.dart:81:10)
E/flutter (21157):
E/flutter (21157): #3 _SplashState.workFlow (package:clarity_alarm/splash.dart:147:5)
E/flutter (21157):

What package are you using? What version?

stream_chat_flutter: ^2.0.0-nullsafety.6

What platform is it about?

  • Android
  • iOS

in iOS it does not happen, only on Android.

To Reproduce
This is the what returns the top level App widget where we define StreamChat. My guess is that here is where it is throwing the error:

  @override
  Widget build(BuildContext context) {
    final theme = ThemeData(
        primaryColor: AppColors.primaryColorByEnv,
        primaryIconTheme: IconThemeData(color: AppColors.white));

  return GetMaterialApp(
        onInit: init,
        onDispose: dispose,
        title: 'Live Alarm',
        debugShowCheckedModeBanner: false,
        theme: AppColors.mainTheme,
        home: Splash(),
        navigatorObservers: [AnalyticsService.observer],
        builder: (context, child) => StreamChat(
              streamChatThemeData: StreamChatThemeData.fromTheme(theme),
              client: ChatConnection.shared.client,
              onBackgroundEventReceived: onBackgroundEventReceived,
              child: child,
            ));
  }

Expected behavior
Should not throw errors

**Logs **
E/flutter (21157): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
E/flutter (21157): #0 StreamChatClient.connect (package:stream_chat/src/client.dart:529:23)
E/flutter (21157): #1 StreamChatCoreState._subscribeToConnectivityChange. (package:stream_chat_flutter_core/src/stream_chat_core.dart:129:20)
E/flutter (21157): #2 _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter (21157): #3 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (21157): #4 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (21157): #5 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (21157): #6 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (21157): #7 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
E/flutter (21157): #8 _DistinctStream._handleData (dart:async/stream_pipe.dart:442:12)
E/flutter (21157): #9 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
E/flutter (21157): #10 _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter (21157): #11 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (21157): #12 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (21157): #13 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (21157): #14 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (21157): #15 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
E/flutter (21157): #16 _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
E/flutter (21157): #17 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
E/flutter (21157): #18 _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter (21157): #19 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (21157): #20 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (21157): #21 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (21157): #22 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (21157): #23 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
E/flutter (21157): #24 _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
E/flutter (21157): #25 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
E/flutter (21157): #26 _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter (21157): #27 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (21157): #28 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (21157): #29 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (21157): #30 _DelayedData.perform (dart:async/stream_impl.dart:591:14)
E/flutter (21157): #31 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11)
E/flutter (21157): #32 _PendingEvents.schedule. (dart:async/stream_impl.dart:663:7)
E/flutter (21157): #33 _rootRun (dart:async/zone.dart:1346:47)
E/flutter (21157): #34 _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (21157): #35 _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (21157): #36 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1202:23)
E/flutter (21157): #37 _rootRun (dart:async/zone.dart:1354:13)
E/flutter (21157): #38 _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (21157): #39 _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (21157): #40 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1202:23)
E/flutter (21157): #41 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter (21157): #42 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

Paste the output of running flutter doctor -v here.

[✓] Flutter (Channel stable, 2.2.1, on macOS 11.4 20F71 darwin-arm, locale es)
    • Flutter version 2.2.1 at /Users/edi/development/flutter
    • Framework revision 02c026b03c (3 weeks ago), 2021-05-27 12:24:44 -0700
    • Engine revision 0fdb562ac8
    • Dart version 2.13.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/edi/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/edi/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5, Build version 12E262
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] IntelliJ IDEA Community Edition (version 2020.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.56.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.23.0


Additional context
It started happening recently, however, downgrading to version 2.0.0-nullsafety.4 didn't helped

@poqueque poqueque added the bug Something isn't working label Jun 17, 2021
@imtoori
Copy link
Contributor

imtoori commented Jun 17, 2021

Hi @poqueque
Sorry about this, this commit should fix the error
We're gonna publish a new version as soon as possible, you can try using the dependency from git in the meantime

@poqueque
Copy link
Author

I'm trying with:

  stream_chat_flutter:
    git:
      url: https://github.com/GetStream/stream-chat-flutter.git
      path: packages/stream-chat-flutter

but I got:

Could not find a file named "packages/stream-chat-flutter/pubspec.yaml"

Any clue to properly add the dependency?

@xsahil03x
Copy link
Contributor

xsahil03x commented Jun 17, 2021

@poqueque something like this

dependencies:   
  stream_chat_flutter:
     git:
       url: https://github.com/GetStream/stream-chat-flutter.git
       ref: develop
       path: ./packages/stream_chat_flutter

@imtoori
Copy link
Contributor

imtoori commented Jun 17, 2021

the fix is out with version 2.0.0-nullsafety.7
sorry for the inconvenience

@imtoori imtoori closed this as completed Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants