NsfwPlatformInterface class abstract
Platform-interface contract for nsfw_detect.
Methods are split into two groups:
- Lifecycle / critical (abstract — every implementation must provide them): permission, model listing, scan lifecycle, single-asset scan, and the raw event stream. Without these the plugin cannot function.
- Optional / feature (default impls below): model download, custom
URL, logging, cache, picker, file/bytes scanning.
Default impls either return safely-ignored values or throw a
UnimplementedErrorwith a clear message. This lets test mocks stub only what they exercise.
- Inheritance
-
- Object
- PlatformInterface
- NsfwPlatformInterface
- Implementers
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
scanEventStream
→ Stream<
Map> -
no setter
Methods
-
availableModels(
) → Future< List< ModelDescriptor> > -
cancelScan(
) → Future< void> -
checkCameraPermission(
) → Future< PermissionStatus> -
checkPermission(
) → Future< PhotoLibraryPermissionStatus> -
clearScanCache(
{String? modelId}) → Future< void> - Clear the persistent scan-result cache. Default no-op.
-
deleteModel(
String modelId) → Future< void> - Delete a previously-downloaded model. Default no-op.
-
downloadModel(
String modelId, {String? url}) → Future< bool> - Download a downloadable model. Default throws.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pickMedia(
{required String type, required bool multiple, int? maxItems}) → Future< List< Map> > - Pure media picker (no classification). Default throws.
-
preloadModel(
String modelId) → Future< void> - Compile / warm the model. Default no-op so test mocks don't need to stub.
-
requestCameraPermission(
) → Future< PermissionStatus> -
requestPermission(
) → Future< PhotoLibraryPermissionStatus> -
resetScan(
) → Future< void> - Reset scan state (clears native checkpoints, etc.). Default no-op.
-
scanFilePath(
String filePath, {String? modelId}) → Future< Map> - Scan an image file from path. Default throws.
-
scanImageBytes(
Uint8List bytes, {String? modelId}) → Future< Map> - Scan raw image bytes. Default throws.
-
scanSingleAsset(
String localIdentifier, {String? modelId}) → Future< Map> -
setLogging(
bool enabled) → Future< void> - Toggle native logging. Default no-op.
-
setModelUrl(
String modelId, String url) → Future< void> - Set a custom download URL for a model. Default no-op.
-
startCameraScan(
CameraConfiguration config) → Future< void> -
startPickAndScan(
ScanConfiguration config, int maxItems) → Future< void> - Picker scan. Default throws — enable by overriding in your native impl.
-
startScan(
ScanConfiguration config) → Future< void> -
stopCameraScan(
) → Future< void> -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance ↔ NsfwPlatformInterface
-
getter/setter pair