diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/rapid_order_bloc.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/rapid_order_bloc.dart index 2a12d9c3..7967b166 100644 --- a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/rapid_order_bloc.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/rapid_order_bloc.dart @@ -47,18 +47,24 @@ class RapidOrderBloc extends Bloc ) async { if (state is RapidOrderInitial) { final RapidOrderInitial currentState = state as RapidOrderInitial; - final bool newListeningState = !currentState.isListening; + final bool alreadyListening = currentState.isListening; - if (newListeningState) { - // Start Recording - await _audioRecorderService.startRecording(); - emit(currentState.copyWith(isListening: true)); + if (!alreadyListening) { + // Start recording + await handleError( + emit: (RapidOrderState s) => emit(s), + action: () async { + await _audioRecorderService.startRecording(); + emit(currentState.copyWith(isListening: true)); + }, + onError: (String errorKey) => RapidOrderFailure(errorKey), + ); } else { - // Stop Recording and Transcribe + // Stop and transcribe emit(currentState.copyWith(isListening: false)); await handleError( - emit: emit.call, + emit: (RapidOrderState s) => emit(s), action: () async { final String? path = await _audioRecorderService.stopRecording(); if (path != null) { @@ -109,10 +115,4 @@ class RapidOrderBloc extends Bloc emit((state as RapidOrderInitial).copyWith(message: cleanedExample)); } } - - @override - Future close() { - _audioRecorderService.dispose(); - return super.close(); - } } diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/create_order/create_order_view.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/create_order/create_order_view.dart index 0c39efdd..a554bf52 100644 --- a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/create_order/create_order_view.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/create_order/create_order_view.dart @@ -3,7 +3,6 @@ import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter_modular/flutter_modular.dart'; import 'package:krow_core/core.dart'; -import 'package:krow_domain/krow_domain.dart'; import '../../utils/constants/order_types.dart'; import '../../utils/ui_entities/order_type_ui_metadata.dart'; import '../order_type_card.dart';