Built-in portable file type with range reads and explicit resource disposal. No third-party package dependency.
TxFile.fromData
| Parameter | Type | Default | Meaning |
|---|---|---|---|
| bytes | Uint8List | required | File contents in memory. |
| name | String | required | Input field name or file name. |
| mimeType | String? | null | Optional MIME type. |
TxFile.fromPath
| Parameter | Type | Default | Meaning |
|---|---|---|---|
| path | String | required | Native filesystem path; unavailable in browsers. |
| name | String? | null | Input field name or file name. |
| mimeType | String? | null | Optional MIME type. |
| Member / type / return | Meaning |
|---|---|
String get name | Input field name or file name. |
String? get mimeType | Optional MIME type. |
String? get path | Native filesystem path; unavailable in browsers. |
Future<int> length() | Returns the file size in bytes. |
Future<Uint8List> readAsBytes() | Reads all contents; prefer openRead for large files. |
Stream<List<int>> openRead([int start = 0, int? end]) | Reads from inclusive start to exclusive end; defaults to the entire file. |
Future<void> dispose() | Stops queries and listeners; do not use the instance afterward. |
import 'dart:typed_data';
import 'package:tecexpress/tecexpress.dart';
Future<void> example() async {
final file = TxFile.fromData(Uint8List.fromList([72, 105]), name: 'hello.txt');
print(await file.readAsBytes());
await file.dispose();
}