diff --git a/packages/neon/neon/lib/src/blocs/apps.dart b/packages/neon/neon/lib/src/blocs/apps.dart index d3727017..b0586b37 100644 --- a/packages/neon/neon/lib/src/blocs/apps.dart +++ b/packages/neon/neon/lib/src/blocs/apps.dart @@ -165,9 +165,7 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates unawaited(appVersions.close()); for (final app in _allAppImplementations) { - for (final bloc in app.blocs.values) { - bloc.dispose(); - } + app.dispose(); } } diff --git a/packages/neon/neon/lib/src/models/app_implementation.dart b/packages/neon/neon/lib/src/models/app_implementation.dart index fd59adc4..83aa5c47 100644 --- a/packages/neon/neon/lib/src/models/app_implementation.dart +++ b/packages/neon/neon/lib/src/models/app_implementation.dart @@ -29,12 +29,15 @@ abstract class AppImplementation String name(final BuildContext context) => nameFromLocalization(AppLocalizations.of(context)); late final R options; + + @protected R buildOptions(final AppStorage storage); - final Map blocs = {}; + final Map _blocs = {}; - T getBloc(final Account account) => blocs[account.id] ??= buildBloc(account); + T getBloc(final Account account) => _blocs[account.id] ??= buildBloc(account); + @protected T buildBloc(final Account account); Provider get blocProvider => Provider( @@ -107,6 +110,9 @@ abstract class AppImplementation void dispose() { options.dispose(); + for (final bloc in _blocs.values) { + bloc.dispose(); + } } /// A custom theme that will be injected into the widget tree.