FileSource class final

A DataSource backed by a file on disk. Native platforms only.

Reads arbitrary offsets with positioned reads — each call returns only the bytes asked for, so the source holds one chunk at a time, never the whole file. The engine pulls a 7 GB PDF in the same small (≤64KB) bites as a 7 KB one.

import 'package:pdf_manipulator/io.dart';

final source = await FileSource.open(File('/path/to/big.pdf'));
try {
  final doc = await pdf.open(source);
  ...
} finally {
  await source.close();
}

Web has no filesystem; this class is exported from package:pdf_manipulator/io.dart (not the main library) so web builds never pull in dart:io. On web, use BlobSource from package:pdf_manipulator/web.dart.

Implemented types

Properties

hashCode → int
The hash code for this object.
no setterinherited
length → int
Total size in bytes.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() → Future<void>
Waits for the reads in flight, then releases the file handle. Idempotent.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readAt(int offset, int count) → Future<Uint8List>
Read count bytes starting at offset.
override
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

open(File file) → Future<FileSource>
Opens file and reads its length. Holds one file handle until close; the file must exist and not be truncated while operations read it.