Browse Source

Made showing the success state configurable in MenuItemWidget

ashilkn 2 years ago
parent
commit
dad5f8075e
1 changed files with 12 additions and 3 deletions
  1. 12 3
      lib/ui/components/menu_item_widget/menu_item_widget.dart

+ 12 - 3
lib/ui/components/menu_item_widget/menu_item_widget.dart

@@ -48,6 +48,10 @@ class MenuItemWidget extends StatefulWidget {
   /// disable gesture detector if not used
   /// disable gesture detector if not used
   final bool isGestureDetectorDisabled;
   final bool isGestureDetectorDisabled;
 
 
+  ///Success state will not be shown if this flag is set to true, only idle and
+  ///loading state
+  final bool showOnlyLoadingState;
+
   const MenuItemWidget({
   const MenuItemWidget({
     required this.captionedTextWidget,
     required this.captionedTextWidget,
     this.isExpandable = false,
     this.isExpandable = false,
@@ -70,6 +74,7 @@ class MenuItemWidget extends StatefulWidget {
     this.isBottomBorderRadiusRemoved = false,
     this.isBottomBorderRadiusRemoved = false,
     this.isTopBorderRadiusRemoved = false,
     this.isTopBorderRadiusRemoved = false,
     this.isGestureDetectorDisabled = false,
     this.isGestureDetectorDisabled = false,
+    this.showOnlyLoadingState = false,
     Key? key,
     Key? key,
   }) : super(key: key);
   }) : super(key: key);
 
 
@@ -192,10 +197,14 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
         .onError((error, stackTrace) => _debouncer.cancelDebounce());
         .onError((error, stackTrace) => _debouncer.cancelDebounce());
     _debouncer.cancelDebounce();
     _debouncer.cancelDebounce();
     if (executionStateNotifier.value == ExecutionState.inProgress) {
     if (executionStateNotifier.value == ExecutionState.inProgress) {
-      executionStateNotifier.value = ExecutionState.successful;
-      Future.delayed(const Duration(seconds: 2), () {
+      if (widget.showOnlyLoadingState) {
         executionStateNotifier.value = ExecutionState.idle;
         executionStateNotifier.value = ExecutionState.idle;
-      });
+      } else {
+        executionStateNotifier.value = ExecutionState.successful;
+        Future.delayed(const Duration(seconds: 2), () {
+          executionStateNotifier.value = ExecutionState.idle;
+        });
+      }
     }
     }
   }
   }