From 26dcceffaeb849bdf539933f89ba9fa0c815dd17 Mon Sep 17 00:00:00 2001 From: spinel Date: Wed, 27 Oct 2021 21:42:11 +0200 Subject: [PATCH] delay progress indicator display --- TODO | 3 ++- lib/components/progress_indicator.dart | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index a0814df..d93420a 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,4 @@ Todo: - ☐ Item + ☐ add active/deleted flag to all data models + ☐ place dropdown items right below their input \ No newline at end of file diff --git a/lib/components/progress_indicator.dart b/lib/components/progress_indicator.dart index 9544161..1e52b69 100644 --- a/lib/components/progress_indicator.dart +++ b/lib/components/progress_indicator.dart @@ -21,11 +21,17 @@ class ViewWithProgressIndicator extends StatefulWidget { } class _ViewWithProgressIndicatorState extends State { + + @override Widget build(BuildContext context) { switch (widget.snapshot.connectionState) { case ConnectionState.none: case ConnectionState.waiting: + Widget progressIndicator = Container(); + // Future.delayed(const Duration(milliseconds: 100)).then((_) => { + // progressIndicator = const CircularProgressIndicator() + // }); return Container( alignment: Alignment.center, padding: widget.padding, @@ -33,8 +39,15 @@ class _ViewWithProgressIndicatorState extends State { child: SizedBox( width: widget.progressIndicatorSize, height: widget.progressIndicatorSize, - // TODO: only show if loading takes longer than 30ms - child: const CircularProgressIndicator(), + child: FutureBuilder( + future: Future.delayed(const Duration(seconds: 1)), + builder: (context, wait) { + if (wait.connectionState != ConnectionState.waiting) { + return const CircularProgressIndicator(); + } + return Container(); + } + ), ), ), );