Skip to content
pubscout

tar

2.1.0, released 6 days ago by simonbinder.eu

Memory-efficient, streaming implementation of the tar file format

WASM-readyRock solid
$ flutter pub add tar
Source repository

What it does

Provides stream-based readers and writers for tar files. It supports various tar formats including v7, ustar, pax, gnu, and star archives, along with handling long file names.

AI-written summary of version 2.0.3, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to read or write large tar archives in a memory-efficient way
  • You are working with streams of bytes to process archives on the fly

Skip it when

  • You need synchronous tar parsing from standard buffers without streams
  • You need automatic security validation against path traversal attacks (like ../) when extracting untrusted archives

Strengths

  • Consumes considerably less memory than package:archive when handling large files
  • Hardened against denial-of-service attacks with invalid tar file headers
  • Supports compilation to JavaScript and runs on Node.js

Weaknesses

  • Slightly slower than alternative buffered implementations due to async stream overhead
  • Does not automatically validate against malicious path traversal or tar bombs in untrusted archives

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
3
import 'dart:convert';
import 'dart:io';
import 'package:tar/tar.dart';

Future<void> main() async {
  final reader = TarReader(File('file.tar').openRead());

  while (await reader.moveNext()) {
    final entry = reader.current;
    print(entry.header.name);
    print(await entry.contents.transform(utf8.decoder).first);
  }
}

Alternatives

Packages that do the same job and could replace tar.

  • archive

    Choose package:archive if you prefer a simpler non-streaming approach and are working with smaller archives where higher memory usage is acceptable.

Works with

Packages commonly used together with tar: ones it builds on, ones built on it, and its own family.