persistBase method

List<Map<String, dynamic>> persistBase()

Persists the current navigation history to a serializable format Returns a list of maps containing path and extra data for each route

Implementation

List<Map<String, dynamic>> persistBase() {
  try {
    return _steps.map((step) {
      final data = <String, dynamic>{'path': step.path};

      // Only include extra if it exists and is serializable
      final extra = step.currentState.extra?.data;
      if (extra != null && _isSerializable(extra)) {
        data['extra'] = extra;
      }

      return data;
    }).toList();
  } catch (e) {
    // Log error and return empty list as fallback
    debugPrint('Failed to persist navigation history: $e');
    return [];
  }
}