Skip to main content

File Messages

Nexconn Chat UI supports sending, displaying, forwarding, and previewing SDK FileMessage instances. The UI layer uses local file paths and delegates the actual upload and message delivery to BaseChannel.sendMediaMessage.

Send a File

Use ChatProvider.sendFileMessage when your app already has a local file path.

Dart
await chatProvider.sendFileMessage('/local/path/report.pdf');

You can also pass mention metadata when the current channel supports mentions.

Dart
await chatProvider.sendFileMessage(
'/local/path/report.pdf',
mentionUserIds: ['user_1'],
);

Input Panel Integration

The default extension panel includes a file plugin. If no custom resolver is supplied, it opens the platform file picker and sends the selected file.

Dart
ChatPageConfig(
inputConfig: MessageInputConfig(
extensionPlugins: [
MessageInputExtensionPlugin.file(
title: 'File',
mediaPathResolver: (context, plugin) async {
return '/local/path/report.pdf';
},
),
],
),
)

Use mediaDraftResolver instead of mediaPathResolver when you need to return richer local metadata.

If the picker returns null, an empty path, or a path that the SDK cannot upload, the input action should be treated as canceled or failed. Use ChatPageConfig.onAfterSendMessage to observe SDK delivery errors after message params are created.

Preview

FilePreviewPage accepts a FileMessage and provides the default file preview route arguments through NexconnFilePreviewRouteArguments.

Dart
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => FilePreviewPage(fileMessage: fileMessage),
),
);

The file chooser, upload, download, and preview behavior depend on platform permissions and the capabilities exposed by the underlying Nexconn SDK.