Swap hive for hive_ce - #1
Merged
Merged
Conversation
hive is unmaintained; hive_ce is the actively-maintained community continuation, API-compatible for everything this package uses (Box, HiveInterface, registerAdapter/isAdapterRegistered, HiveAesCipher). Two source changes beyond the import swap: - hive_ce's TypeAdapter is a plain `abstract class` analyzed at Dart 3.4+ language version (hive's own copy of the same class stayed mixin-usable only because hive itself pins language version <3.0). HiveLocalAdapter now `implements TypeAdapter<T>` instead of `with TypeAdapter<T>` — safe, since TypeAdapter has no concrete methods to inherit, only abstract members HiveLocalAdapter already implements. - test/mocks.dart's internal-path imports (default_compaction_strategy .dart, default_key_comparator.dart) still resolve under hive_ce at the same paths. `dart analyze` is clean. Could not run the test suite in this environment (local Dart SDK is missing frontend_server.dart.snapshot, unrelated to this change) — run `dart test` in CI/a complete toolchain before relying on this.
Isolated from any other codegen package (riverpod_generator, etc.) a consuming app might also carry — this only proves flutter_data's own builders (data_library_builder, repository_builder) still generate correctly on their own. A consuming app's build_runner failure with other generators in the mix is a separate problem in that app's own dependency graph, not evidence against this fork. Also bumped example/'s own SDK floor to match flutter_data's (Dart 3.4+, required by hive_ce) and its build_runner/json_serializable constraints to current.
The real ask behind this: apps depending on flutter_data were stuck pinning old analyzer/build/build_runner/freezed to satisfy flutter_data's narrow lower-bounds, which in turn blocked those apps from moving to a current Dart/Flutter SDK. Widened every build-time constraint (analyzer, build, source_gen, riverpod) to a broad range instead of a narrow caret, and bumped freezed 2.x->3.x (dev-only, test fixtures). Removed build_resolvers and build_test as explicit dependencies — grep confirmed neither is imported anywhere in lib/ or test/; declaring them narrowed the graph for consumers with nothing to show for it. (build_test is also stuck depending on build ^2.0.0 across its entire published history, and build_resolvers is pub.dev-flagged discontinued.) Resolving against these wider ranges landed analyzer 6.1.0 -> 8.4.1 and source_gen 1.0.1 -> 4.2.0, which is the actual jump apps get once they can stop overriding versions by hand. That surfaced 6 real API changes in the three files that touch analyzer/source_gen directly: - TypeChecker.fromRuntime -> TypeChecker.typeNamed (removed upstream in source_gen; same call shape, straight rename) - Element.location -> element.library!.uri (location was removed in analyzer 8's Element model; library.uri gives the same "package:..." string the old .location.components.first did) - ConstructorElement.parameters -> .formalParameters, returning FormalParameterElement (renamed as part of the same Element model pass) - Element.name is now nullable (String?) throughout; added `!` at the four call sites operating on elements that always have a declared name (fields, methods, params) rather than threading optionality through - getDisplayString(withNullability: false) -> getDisplayString() (the parameter was removed now that non-nullable-by-default is the only mode) dart analyze is clean across lib/, test/, and example/lib/ against the newly-resolved versions (analyzer 8.4.1, source_gen 4.2.0, build_runner 2.6.1, freezed 3.2.3). Test suite and the codegen CI job both still need the pending Actions-enable click to actually run — see PR #1.
The inherited workflow only fired on push/PR to master. Every commit here lives on 1.6.x/hive-ce instead (master diverged onto upstream's sqlite3 rewrite — see the PR #1 base-branch fix), so nothing has run since Actions was enabled on the fork.
dart-lang/setup-dart@v1.5 no longer resolves (tag removed upstream); actions/checkout@v2 bumped alongside it while touching this file.
This is what was actually breaking build_runner/dart test everywhere so far — including on GitHub's own hosted runner, not just locally. frontend_server_client 3.2.0 (what everything here resolves to unforced) can't find frontend_server.dart.snapshot under current Dart SDKs; the fix ships in frontend_server_client 4.0.0, which every transitive constraint already permits, nothing was pinning it low on purpose. See dart-lang/sdk#60198, closed by the reporter's own frontend_server_client upgrade. All 157 tests pass locally now (4s). This is a dependency_override, so it only fixes resolution when this repo itself is the root package — running its own test/codegen CI. It does not propagate to consuming apps automatically; an app hitting the same missing-snapshot error needs the same override in its own pubspec.
Two call sites used bare \`remote\` (after \`remote ??= _remote\`) relying on flow-typing to promote it from bool? to bool — the same pattern this file already guards with \`!\` everywhere else it uses \`remote\`. Dart 3.12.2 (this sandbox) still promotes it here; Dart 3.13.4 (GitHub's runner, current stable) does not, and fails to compile without the explicit assertion. Matched the existing pattern instead of relying on promotion either way. Locally this shows as a harmless "unnecessary '!'" warning, not an error — expected, since 3.12.2 still promotes; 3.13.4 is authoritative here as the actual current stable SDK.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates from the unmaintained
hiveto the actively-maintainedhive_cecommunity continuation. Opened against this fork's own
master(notupstream) specifically to run CI on a clean toolchain and get a real test
result — local analysis is clean but this machine's Dart SDK is missing a
test-runner snapshot.
See the commit message for the two non-mechanical changes (TypeAdapter
mixin→implements, test mock import paths).