Skip to content

Add material_ui support to hive_ce_flutter - #333

Merged
Rexios80 merged 3 commits into
mainfrom
feature/material_ui
Sep 27, 2026
Merged

Rexios80 merged 3 commits into
mainfrom
feature/material_ui

Conversation

@Rexios80

Copy link
Copy Markdown
Member

Summary

Closes #332

  • Adds MaterialUiTimeOfDayAdapter for the TimeOfDay class from package:material_ui. It shares the binary format and default type id (201) with TimeOfDayAdapter, so existing data can be read as either class. TimeOfDayAdapter still targets package:flutter/material.dart, so this is not a breaking change.
  • Adds a useMaterialUi flag to Hive.initFlutter and IsolatedHive.initFlutter to register MaterialUiTimeOfDayAdapter instead of TimeOfDayAdapter (default false).
  • Moves the shared initFlutter logic into an internal initFlutterCommon, which also gives IsolatedHive.initFlutter the absolute path handling from Rename subDir to dir in initFlutter, treat as relative or absolute #293.
  • Adds a material_ui: ^1.0.0 dependency and raises the minimum Flutter version to 3.44.0, which material_ui 1.0.0 requires. Bumps the version to 2.4.0.

Test plan

  • dart format . --set-exit-if-changed
  • dart analyze --fatal-infos
  • flutter test, including new tests that data written by either TimeOfDay adapter reads back correctly with the other, and tests for relative and absolute initFlutter paths
  • flutter build web for the example app
  • Analyzer and tests with material_ui 1.0.0 and hive_ce 2.16.0 (the minimum constraints)
  • CI on the Flutter beta channel

# Conflicts:
#	hive_flutter/CHANGELOG.md
#	hive_flutter/lib/src/hive_extensions.dart

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

Only a minor test-coverage nit remains; no blocking issues were identified.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Adds material_ui support to hive_ce_flutter while preserving existing TimeOfDay compatibility and improving initialization path handling.

Changes:

  • Adds MaterialUiTimeOfDayAdapter and compatibility tests.
  • Adds useMaterialUi to both initialization APIs.
  • Refactors shared initialization and updates dependencies, Flutter constraints, and changelog.
File Summary
hive_flutter/​test/​type_registry_extensions_test.dart Tests initialization path handling.
hive_flutter/​test/​adapters/​time_adapter_test.dart Tests adapter compatibility.
hive_flutter/​pubspec.yaml Updates dependencies and Flutter constraints.
hive_flutter/​lib/​src/​type_registry_extensions.dart Centralizes initialization and adapter registration.
hive_flutter/​lib/​src/​isolated_hive_extensions.dart Updates isolated Hive initialization.
hive_flutter/​lib/​src/​hive_extensions.dart Exposes the new initialization option.
hive_flutter/​lib/​src/​adapters/​time_adapter.dart Adds the Material UI adapter.
hive_flutter/​CHANGELOG.md Documents the release changes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread hive_flutter/lib/src/type_registry_extensions.dart
@codecov

codecov Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.65%. Comparing base (b108e56) to head (6b39eb4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #333   +/-   ##
=======================================
  Coverage   93.65%   93.65%           
=======================================
  Files          66       66           
  Lines        2663     2663           
=======================================
  Hits         2494     2494           
  Misses        169      169           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rexios80 Rexios80 self-assigned this Sep 27, 2026
@Rexios80
Rexios80 merged commit 0987712 into main Sep 27, 2026
26 checks passed
@cedvdb

cedvdb commented Sep 27, 2026 •

Copy link
Copy Markdown

@Rexios80 Pardon my ignorance, but why are those 2 classes TimeOfDayAdapter and ColorAdapter in this database package ? To an outsider, this seems out of scope but i gather it's for convenience / historical reasons ?

@Rexios80

Copy link
Copy Markdown
Member Author

They were added well before Hive CE was a thing. I would say they aren't out of scope. These are commonly used Flutter types (especially Color) that developers would want adapters for.

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.

migrate to material_ui

3 participants