FileNameUtils class

Platform-agnostic filename utilities

These utilities work on all platforms (mobile + web) and have no dart:io dependencies.

Features:

  • Extract base name from filename (remove extensions)
  • Validate file extensions
  • Determine minimum file sizes
  • Generate regex patterns for file matching

Platform Support: All (web + mobile)

Constructors

FileNameUtils()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

extensionRegexPattern → String
Creates regex pattern for matching any supported extension
no setter

Static Methods

getBaseName(String filename) → String
Removes all supported extensions from filename to get base name
getExtension(String filename) → String
Extracts file extension from filename
getMinimumSize(String extension) → int
Gets minimum file size based on extension
hasValidExtension(String filename) → bool
Validates if filename has a supported extension
isFileValid(String filename, int fileSize) → bool
Validates if file meets minimum size requirements
isSmallFile(String extension) → bool
Checks if file extension requires smaller minimum size
namespaced(String modelId, String basename) → String
Prefixes basename with the owning model's modelId so a companion file (a tokenizer, an aux bundle member) never collides on disk or in the install-identity cache key with the SAME basename belonging to a DIFFERENT model (e.g. moonshine's and whisper's tokenizers are both literally named tokenizer.json; embeddinggemma's and Gecko's tokenizers are both literally named sentencepiece.model).
sanitizeHfDirName(String repo, {String? variant}) → String
A filesystem-safe directory name for a DIRECTORY model (ORT-GenAI) installed from a Hugging Face repo. Unlike namespaced (which produces a FLAT modelId__basename prefix), a directory model's files must keep their BARE leaf names inside a real subdirectory — genai_config.json references its siblings by bare name and the native loader is handed the directory.

Constants

supportedExtensions → const List<String>
Supported model file extensions (SINGLE SOURCE OF TRUTH)