Skip to content

Commit 95da571

Browse files
rajveermalviyagnprice
authored andcommitted
store: Make GlobalStoreWidget's loading placeholder blank
This removes the un-styled CircularProgressIndicator that was displayed for a brief moment, instead the user now just sees the default background color. [greg: added TODO-comments on the extra frame that seems to now be needed]
1 parent 9b5a637 commit 95da571

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

lib/widgets/store.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class GlobalStoreWidget extends StatefulWidget {
1919
const GlobalStoreWidget({
2020
super.key,
2121
this.blockingFuture,
22-
this.placeholder = const LoadingPlaceholder(),
22+
this.placeholder = const BlankLoadingPlaceholder(),
2323
required this.child,
2424
});
2525

@@ -341,6 +341,15 @@ class _PerAccountStoreInheritedWidget extends InheritedNotifier<PerAccountStore>
341341
store != oldWidget.store;
342342
}
343343

344+
class BlankLoadingPlaceholder extends StatelessWidget {
345+
const BlankLoadingPlaceholder({super.key});
346+
347+
@override
348+
Widget build(BuildContext context) {
349+
return const SizedBox.shrink();
350+
}
351+
}
352+
344353
class LoadingPlaceholder extends StatelessWidget {
345354
const LoadingPlaceholder({super.key});
346355

test/widgets/store_test.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ void main() {
7070
return const SizedBox.shrink();
7171
})));
7272
// First, shows a loading page instead of child.
73-
check(find.byType(CircularProgressIndicator)).findsOne();
73+
check(find.byType(BlankLoadingPlaceholder)).findsOne();
7474
check(globalStore).isNull();
7575

7676
await tester.pump();
7777
// Then after loading, mounts child instead, with provided store.
78-
check(find.byType(CircularProgressIndicator)).findsNothing();
78+
check(find.byType(BlankLoadingPlaceholder)).findsNothing();
7979
check(globalStore).identicalTo(testBinding.globalStore);
8080

8181
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot());
@@ -98,14 +98,15 @@ void main() {
9898
await tester.pump();
9999
// Even after the store must have loaded,
100100
// still shows loading page while blockingFuture is pending.
101-
check(find.byType(CircularProgressIndicator)).findsOne();
101+
check(find.byType(BlankLoadingPlaceholder)).findsOne();
102102
check(find.text('done')).findsNothing();
103103

104104
// Once blockingFuture completes…
105105
completer.complete();
106106
await tester.pump();
107+
await tester.pump(); // TODO why does GlobalStoreWidget need this extra frame?
107108
// … mounts child instead of the loading page.
108-
check(find.byType(CircularProgressIndicator)).findsNothing();
109+
check(find.byType(BlankLoadingPlaceholder)).findsNothing();
109110
check(find.text('done')).findsOne();
110111
});
111112

@@ -123,14 +124,15 @@ void main() {
123124
await tester.pump();
124125
// Even after the store must have loaded,
125126
// still shows loading page while blockingFuture is pending.
126-
check(find.byType(CircularProgressIndicator)).findsOne();
127+
check(find.byType(BlankLoadingPlaceholder)).findsOne();
127128
check(find.text('done')).findsNothing();
128129

129130
// Once blockingFuture completes, even with an error…
130131
completer.completeError(Exception('oops'));
131132
await tester.pump();
133+
await tester.pump(); // TODO why does GlobalStoreWidget need this extra frame?
132134
// … mounts child instead of the loading page.
133-
check(find.byType(CircularProgressIndicator)).findsNothing();
135+
check(find.byType(BlankLoadingPlaceholder)).findsNothing();
134136
check(find.text('done')).findsOne();
135137
});
136138

0 commit comments

Comments
 (0)