Skip to content

Commit 1614322

Browse files
committed
settings [nfc]: Have inherited widget use GlobalSettingsStore directly
This gives _GlobalSettingsStoreInheritedWidget essentially the same structure as _GlobalStoreInheritedWidget, which hopefully makes the pair of them a bit easier to think about.
1 parent f177fe0 commit 1614322

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/widgets/store.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class GlobalStoreWidget extends StatefulWidget {
7272
static GlobalSettingsData settingsOf(BuildContext context) {
7373
final widget = context.dependOnInheritedWidgetOfExactType<_GlobalSettingsStoreInheritedWidget>();
7474
assert(widget != null, 'No GlobalStoreWidget ancestor');
75-
return widget!.store.globalSettings;
75+
return widget!.store.data;
7676
}
7777

7878
@override
@@ -109,7 +109,8 @@ class _GlobalStoreInheritedWidget extends InheritedNotifier<GlobalStore> {
109109
required GlobalStore store,
110110
required Widget child,
111111
}) : super(notifier: store,
112-
child: _GlobalSettingsStoreInheritedWidget(store: store, child: child));
112+
child: _GlobalSettingsStoreInheritedWidget(
113+
store: store.settingsNotifier, child: child));
113114

114115
GlobalStore get store => notifier!;
115116
}
@@ -118,12 +119,12 @@ class _GlobalStoreInheritedWidget extends InheritedNotifier<GlobalStore> {
118119
// [GlobalSettingsStore] instead of the overall [GlobalStore].
119120
// That enables [settingsOf] to do the same.
120121
class _GlobalSettingsStoreInheritedWidget extends InheritedNotifier<GlobalSettingsStore> {
121-
_GlobalSettingsStoreInheritedWidget({
122-
required this.store,
122+
const _GlobalSettingsStoreInheritedWidget({
123+
required GlobalSettingsStore store,
123124
required super.child,
124-
}) : super(notifier: store.settingsNotifier);
125+
}) : super(notifier: store);
125126

126-
final GlobalStore store;
127+
GlobalSettingsStore get store => notifier!;
127128
}
128129

129130
/// Provides access to the user's data for a particular Zulip account.

0 commit comments

Comments
 (0)