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

Type Null is not a subtype of string in hive type adapter. #789

Closed
incrediblezayed opened this issue Sep 15, 2021 · 3 comments
Closed

Type Null is not a subtype of string in hive type adapter. #789

incrediblezayed opened this issue Sep 15, 2021 · 3 comments
Labels
problem An unconfirmed bug.

Comments

@incrediblezayed
Copy link

Steps to Reproduce

  1. Create a model class.
  2. Generate & Register the type adapter
  3. Open the box for that type.

Code sample

@HiveType(typeId: 0)
class UserModel {
  @HiveField(0)
  String id;

  @HiveField(1)
  String username;

  @HiveField(2)
  String displayName;

  @HiveField(3)
  String email;

  @HiveField(4)
  String phoneNumber;
  UserModel({
    required this.id,
    required this.username,
    required this.displayName,
    required this.email,
    required this.phoneNumber,
  });
}

Log:
E/flutter (29302): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: type 'Null' is not a subtype of type 'String' in type cast
E/flutter (29302): #0 UserModelAdapter.read
package:justpoll/model/user_model.g.dart:22
E/flutter (29302): #1 BinaryReaderImpl.read
package:hive/…/binary/binary_reader_impl.dart:326
E/flutter (29302): #2 BinaryReaderImpl.readFrame
package:hive/…/binary/binary_reader_impl.dart:274
E/flutter (29302): #3 FrameHelper.framesFromBytes
package:hive/…/binary/frame_helper.dart:21
E/flutter (29302): #4 FrameIoHelper.framesFromFile
package:hive/…/io/frame_io_helper.dart:42
E/flutter (29302):
Launching lib\main.dart on M2101K6I in debug mode...
package:justpoll/main.dart:1
E/flutter (29302): #5 StorageBackendVm.initialize
package:hive/…/vm/storage_backend_vm.dart:86
E/flutter (29302):
E/flutter (29302): #6 HiveImpl._openBox
package:hive/src/hive_impl.dart:116
E/flutter (29302):
E/flutter (29302): #7 HiveImpl.openBox
package:hive/src/hive_impl.dart:145
E/flutter (29302):
E/flutter (29302): #8 HiveDataHelper.initBox
package:justpoll/utils/hive_helper.dart:44
E/flutter (29302):
E/flutter (29302): #9 HiveDataHelper.init
package:justpoll/utils/hive_helper.dart:27
E/flutter (29302):
E/flutter (29302): #10 main
package:justpoll/main.dart:14
E/flutter (29302):
E/flutter (29302):

Version

  • Platform: iOS, Android, Mac, Windows, Linux, Web
  • Flutter version: 2.2.3
  • Hive version: 2.0.4
  • Hive Flutter: 1.1.0
  • Hive Generator: 1.1.0
  • Build Runner: 2.1.0
@incrediblezayed incrediblezayed added the problem An unconfirmed bug. label Sep 15, 2021
@pishguy
Copy link

pishguy commented Sep 19, 2021

@incrediblezayed problem is on your implementations. please ask in www.stackoverflow.com

@incrediblezayed
Copy link
Author

incrediblezayed commented Sep 20, 2021

Hello @pishguy, but the same implementation works in my other apps.

@incrediblezayed
Copy link
Author

I had to recreate the app.

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

No branches or pull requests

2 participants