onEnd method

void onEnd()

Implementation

void onEnd() {
  __.in_('onEnd');
  try {
    __.info('Flow ended: $flowType');
    trackFlowEnd(flowType.name);
    // Calculate flow duration if we have a start time
    if (flowState.containsKey('startTime')) {
      final startTime = flowState['startTime'] as int;
      final duration = DateTime.now().millisecondsSinceEpoch - startTime;
      __.info('Flow duration: ${duration}ms');
    }

    // Clear the state
    //TODO: Commenting to test, we need this to be enabled.
    // flowState.clear();
    flowState.removeWhere((key, value) => key != 'appUser');

    // Notify flow manager
    // ignore: invalid_use_of_protected_member
    if (_navigationService?.flowManager != null) {
      // ignore: invalid_use_of_protected_member
      _navigationService?.flowManager.endFlow(flowType);
    }
  } catch (e, stackTrace) {
    __.severe('Error in onEnd', e, stackTrace);
  } finally {
    __.out_('onEnd');
  }
}