From 93d3dfaf5cbe4c0b941e927c7b06dd36c9967486 Mon Sep 17 00:00:00 2001 From: harshyadavDeveloper Date: Thu, 30 Apr 2026 12:18:36 +0530 Subject: [PATCH] docs: clarify HomeViewModel lifecycle in Compass sample --- compass_app/app/lib/routing/router.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/compass_app/app/lib/routing/router.dart b/compass_app/app/lib/routing/router.dart index 1ed94ed02..381a3945f 100644 --- a/compass_app/app/lib/routing/router.dart +++ b/compass_app/app/lib/routing/router.dart @@ -42,6 +42,16 @@ GoRouter router(AuthRepository authRepository) => GoRouter( GoRoute( path: Routes.home, builder: (context, state) { + // NOTE: + // HomeViewModel is created here and is not disposed. + // This is safe in this sample because HomeViewModel does not + // manage any resources that require disposal. + // + // In real applications, if a ViewModel manages streams, + // controllers, or subscriptions, it should be properly disposed. + // This can be handled using state management solutions such as + // Provider or Riverpod, or by managing lifecycle within a + // StatefulWidget. final viewModel = HomeViewModel( bookingRepository: context.read(), userRepository: context.read(),