init method

bool init({
  1. required String collectionPath,
  2. String? metadataPath,
  3. bool saveToMemory = false,
  4. bool hasHeaders = true,
})

Initializes the IO utility with the given file paths and options.

collectionPath is required and specifies the path to the word collection file. metadataPath is optional and specifies the path to the metadata file. saveToMemory determines if file contents should be cached in memory. hasHeaders specifies if the files have header rows.

Returns true if initialization is successful.

Implementation

bool init({
  required String collectionPath,
  String? metadataPath,
  bool saveToMemory = false,
  bool hasHeaders = true,
}) {
  _collectionPath = collectionPath;
  if (metadataPath != null && metadataPath.isNotEmpty) {
    _metadataPath = metadataPath;
  }
  if (this.collectionPath != null && this.collectionPath!.isNotEmpty) {
    _isInitialized = true;
  }

  _saveToMemory = saveToMemory;
  _hasHeaders = hasHeaders;

  return isInitialized;
}