refactor(tracking): tighten sf_tracking package

- Lazy-init sfTracking to avoid touching Firebase at import time
- DRY SfTrackingRepository with a single _broadcast helper
- Drop empty DashboardTracking, fix double step_completed in device_setup
- Move yearsBetween to packages/utils
- Add 5 unit tests for SfTrackingRepository
- Strip noisy comments from mixins and view models
This commit is contained in:
2026-04-07 16:59:38 +02:00
parent 4728e25803
commit 42ec003b05
27 changed files with 295 additions and 517 deletions

View File

@@ -0,0 +1,10 @@
/// Returns the number of full years between [from] and [to], using the
/// classic "have we already passed the birthday this year?" rule. Returns
/// 0 if [from] is in the future relative to [to].
int yearsBetween(DateTime from, DateTime to) {
var years = to.year - from.year;
final hasNotReachedAnniversary =
to.month < from.month || (to.month == from.month && to.day < from.day);
if (hasNotReachedAnniversary) years -= 1;
return years < 0 ? 0 : years;
}

View File

@@ -1,2 +1,3 @@
export 'src/date_utils.dart';
export 'src/size_utils.dart';
export 'src/test.dart';