dart_smb2 0.0.1+1 copy "dart_smb2: ^0.0.1+1" to clipboard
dart_smb2: ^0.0.1+1 copied to clipboard

Flutter SMB2/3 built on top of libsmb2. Targets macOS, Windows, Linux, iOS and Android.

example/dart_smb2_example.dart

import 'package:dart_smb2/dart_smb2.dart';

/// Example: connect to an SMB share and list files.
///
/// Run with:
///   dart run example/dart_smb2_example.dart
void main() {
  final client = Smb2Client.open('path/to/libsmb2_wrapper.dylib');

  try {
    // Connect to a share
    client.connect(
      host: '192.168.1.100',
      share: 'Music',
      user: 'guest',
      password: '',
    );
    print('Connected!');

    // List root directory (use '' for root, not '/')
    final entries = client.listDirectory('');
    for (final entry in entries) {
      final icon = entry.isDirectory ? '[DIR] ' : '[FILE]';
      print('$icon ${entry.name}  (${entry.size} bytes)');
    }

    // Read first 256 KB of a file (e.g. audio metadata header)
    final header = client.readFileRange(
      'Artist/Album/01. Track.m4a',
      length: 256 * 1024,
    );
    print('Read ${header.length} bytes');

    // Read an entire file (e.g. a cover image)
    final image = client.readFile('Artist/Album/cover.jpg');
    print('Image: ${image.length} bytes');

    // Get file info without opening it
    final info = client.stat('Artist/Album/01. Track.m4a');
    print('Size: ${info.size}, Modified: ${info.modified}');
  } finally {
    client.disconnect();
  }
}
3
likes
0
points
118
downloads

Publisher

verified publisherales-drnz.com

Weekly Downloads

Flutter SMB2/3 built on top of libsmb2. Targets macOS, Windows, Linux, iOS and Android.

Repository (GitHub)
View/report issues

Topics

#cross-platform #smb2 #smb3 #libsmb2

License

unknown (license)

Dependencies

ffi

More

Packages that depend on dart_smb2

Packages that implement dart_smb2