onLoadData method

  1. @override
Future<void> onLoadData()
override

Implementation

@override
Future<void> onLoadData() async {
  try {
    _isLoading = true;
    rebuild();

    // Detect source type
    _sourceType = _detectSourceType(text);

    // Load file based on source type
    switch (_sourceType) {
      case FileSourceType.base64:
        await _loadFromBase64();
        break;
      case FileSourceType.path:
        await _loadFromPath();
        break;
      case FileSourceType.url:
        await _loadFromUrl();
        break;
      default:
        throw Exception(setText('Định dạng không hợp lệ', 'Invalid format'));
    }

    _isLoading = false;
    _errorMessage = null;
    rebuild();
  } catch (e) {
    _isLoading = false;
    _errorMessage = e.toString();
    rebuild();
  }
}