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

Fix/ HiveError: Could not read value from box. Maybe your box is corrupted. #1268

Merged
merged 7 commits into from
Aug 16, 2024

Conversation

ghassenbenzahra123
Copy link
Contributor

📝 Summary

This PR Fixes #1256

Description

  • Replace dio hive cache store with hive box.

Checklist:

  • Coding Standards: I have reviewed my code to ensure it follows the project's coding standards.
  • Testing: I have tested the changes and they work as expected.
  • Merge Conflicts: I have resolved any merge conflicts with the latest main/development branch.
  • Branch Status: The branch is up-to-date with the target branch (main/development).

@YassinNouh21
Copy link
Contributor

we still need to mange the hive adaptor

image

I create new class

import 'package:dio/dio.dart';
import 'package:hive_flutter/adapters.dart';

part 'cache_response_model.g.dart';

@HiveType(typeId: 4)
class CacheResponseModel {
  @HiveField(0)
  final Map<String, dynamic> data;

  @HiveField(1)
  final String? lastModified;

  CacheResponseModel({
    required this.data,
    this.lastModified,
  });
}

@YassinNouh21
Copy link
Contributor

YassinNouh21 commented Aug 15, 2024

I came up with this solution we need to discuss it more

hive.patch

- Introduce CacheLocalDataSource for managing Hive box operations
- Refactor ApiCacheInterceptor to use CacheLocalDataSource
- Add HTTP header constants and content type checks
- Implement proper handling for 304 Not Modified responses
- Improve error handling with CrashlyticsWrapper
- Remove direct Hive operations from ApiCacheInterceptor
- Update Api.dart to use new CacheLocalDataSource
- Add Riverpod providers for dependency injection
- Enhance response validation in Dio BaseOptions
@ghassenbenzahra123 ghassenbenzahra123 merged commit cfe750a into main Aug 16, 2024
1 check passed
@ghassenbenzahra123 ghassenbenzahra123 deleted the fix/hive-error-corrupted-box branch August 16, 2024 19:48
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

Successfully merging this pull request may close these issues.

HiveError: HiveError: Could not read value from box. Maybe your box is corrupted.
2 participants