fix: flutter: LateInitializationError: Field '__storage@230190796' has not been initialized. #4341
Labels
bug
Something isn't working
needs repro info
The issue is missing a reproduction sample and/or steps
question
Further information is requested
waiting for response
Waiting for follow up
HydratedBloc.storage = await HydratedStorage.build(
storageDirectory: kIsWeb
? HydratedStorageDirectory.web
: HydratedStorageDirectory((await getTemporaryDirectory()).path),
);
and
....
ProfileModel? get profile => _profile;
String? get profileImage => _profileImage;
@OverRide
ProfileState? fromJson(Map<String, dynamic> json) {
try {
// Deserialize JSON to profile state
final profileData = json['profile'] != null
? ProfileModel.fromJson(json['profile'])
: null;
}
Future<List> getAddress(String? search) async {
final res = await _searchAddressUseCase.call(search);
}
@OverRide
Map<String, dynamic>? toJson(ProfileState state) {
if (state is ProfileGetDataSuccessState) {
// Serialize the profile state into JSON
return {
'profile': profile?.toJson(),
'dateTime': dateTime,
};
}
return null;
}
}
but flutter: LateInitializationError: Field '__storage@230190796' has not been initialized.
The text was updated successfully, but these errors were encountered: