fromNetwork method
Set model source from network URL (HTTP/HTTPS)
Parameters:
url: The HTTP/HTTPS URL to download fromtoken: Optional authentication token (e.g., HuggingFace token)foreground: Android foreground service mode (shows notification, no timeout)- null (default): NO foreground service — this branch configures no notification, and the platform needs one before it starts the service
- true: always use foreground
- false: never use foreground
filename: the name the file is installed under instead of the URL's file name, with the same extension.isModelInstalled,getModelPathanduninstallModelthen take this name.expectedSize: the file's size in bytes once downloaded, checked on every install before the model becomes active, a file installed earlier included. A file of another size is deleted with its record and install throws ModelValidationException; a negative size throws ArgumentError here. With it set, install throws StateError before the download when it would replace a file of this name that an active model of any kind reads (one not installed yet, or installed from another source): uninstall that model first. On the web neither is checked.
Implementation
InferenceInstallationBuilder fromNetwork(
String url, {
String? token,
bool? foreground,
String? filename,
int? expectedSize,
}) {
final expected = FileExpectation.checked(size: expectedSize);
_clearSource();
_modelSource = ModelSource.network(
url,
authToken: token,
foreground: foreground,
);
_filename = filename;
_expected = expected;
return this;
}