Skip to content

Error loading storage #148

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

Closed
amrgetment opened this issue Apr 2, 2025 · 9 comments
Closed

Error loading storage #148

amrgetment opened this issue Apr 2, 2025 · 9 comments

Comments

@amrgetment
Copy link

I got this error, and I am using version 1.1.4

I/flutter ( 4128): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 4128): │ #0   SystemLogger.parseLog (package:segment_analytics/logger.dart:80:16)
I/flutter ( 4128): │ #1   log (package:segment_analytics/logger.dart:106:23)
I/flutter ( 4128): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 4128): │ ⛔ Segment: An internal error occurred: Error loading storage: type 'Null' is not a subtype of type 'bool' in type cast
I/flutter ( 4128): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
E/flutter ( 4128): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: Error loading storage: type 'Null' is not a subtype of type 'bool' in type cast
E/flutter ( 4128): #0      PersistedState.init.<anonymous closure> (package:segment_analytics/state.dart:217:7)
E/flutter ( 4128): #1      _FutureListener.handleError (dart:async/future_impl.dart:222:22)
E/flutter ( 4128): #2      Future._propagateToListeners.handleError (dart:async/future_impl.dart:914:47)
E/flutter ( 4128): #3      Future._propagateToListeners (dart:async/future_impl.dart:935:13)
E/flutter ( 4128): #4      Future._completeError (dart:async/future_impl.dart:715:5)
E/flutter ( 4128): <asynchronous suspension>
E/flutter ( 4128): 
I/flutter ( 4128): FlutterFire Messaging: An error occurred in your background messaging handler:
I/flutter ( 4128): Null check operator used on a null value
I/flutter ( 4128): ----------------FIREBASE CRASHLYTICS----------------
I/flutter ( 4128): type 'Null' is not a subtype of type 'bool' in type cast
I/flutter ( 4128): #0      _$ContextNetworkFromJson (package:segment_analytics/event.g.dart:462:25)
I/flutter ( 4128): #1      JSONExtendable.fromJson (package:segment_analytics/event.dart:568:28)
I/flutter ( 4128): #2      new ContextNetwork.fromJson (package:segment_analytics/event.dart:507:22)
I/flutter ( 4128): #3      _$ContextFromJson (package:segment_analytics/event.g.dart:345:22)
I/flutter ( 4128): #4      JSONExtendable.fromJson (package:segment_analytics/event.dart:568:28)
I/flutter ( 4128): #5      new Context.fromJson (package:segment_analytics/event.dart:365:22)
I/flutter ( 4128): #6      ContextState.fromJson (package:segment_analytics/state.dart:384:20)
I/flutter ( 4128): #7      PersistedState.init.<anonymous closure> (package:segment_analytics/state.dart:200:13)
I/flutter ( 4128): <asynchronous suspension>
I/flutter ( 4128): ----------------------------------------------------

Image
@amrgetment
Copy link
Author

amrgetment commented Apr 2, 2025

I think it is related to json['bluetooth'] as bool in the following class

https://github.com/segmentio/analytics_flutter/blob/main/packages/core/lib/event.g.dart

ContextNetwork _$ContextNetworkFromJson(Map<String, dynamic> json) =>
    ContextNetwork(
      json['cellular'] as bool,
      json['wifi'] as bool,
      json['bluetooth'] as bool,
      custom: json['custom'] as Map<String, dynamic>?,
    );

@amrgetment
Copy link
Author

I tried version 1.1.3 and same issue

@Anderzzon
Copy link

To me it helped to delete the app and then reinstall it. But it would be nice if this was fixed so we don't get this error in production

@amrgetment
Copy link
Author

I will keep my app as if I deleted it I won't be able to reproduce the issue and in production users upgrade not delete the app
Thanks Anderzzon for sharing this tip

@amrgetment
Copy link
Author

Image

@amrgetment
Copy link
Author

@MichaelGHSeg could you make a hotfix for this issue
It is pretty simple json[Bluetooth] as bool? or (json[Bluetooth] as bool?) ?? false

@MichaelGHSeg
Copy link
Contributor

Thanks for your work on this issue, we'll get it taken care of.

@MichaelGHSeg
Copy link
Contributor

Sorry, deadlines and other issues. Give 1.1.6 a try and let us know if you have any more issues. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants