Skip to main content

time_travel_debugger 1.0.0 copy "time_travel_debugger: ^1.0.0" to clipboard
time_travel_debugger: ^1.0.0 copied to clipboard

Ultra-Pro time-travel debugger for Dart & Flutter that records state changes and lets you rewind execution step-by-step to inspect variables, memory, and app state at any point.

๐Ÿ•ฐ time_travel_debugger #

Ultra-Pro time-travel debugging for Dart & Flutter.
Record every state change, then rewind step-by-step to inspect variable values at any point in your execution history.

Dart SDK Flutter License: MIT


image

โœจ Features #

Feature Description
๐Ÿ”ด Live recording Capture every variable mutation with sub-ms overhead
โช Time-travel rewind(n), fastForward(n), jumpTo(step)
๐Ÿ”– Bookmarks Annotate key moments for instant navigation
๐Ÿ”ด Conditional breakpoints Fire on any predicate โ€” log, pause, throw, or rewind
๐Ÿ‘ Watchpoints Pure observers for live analytics without stopping execution
๐Ÿ” DiffEngine Visual diff between any two snapshots
๐Ÿ’พ Session persistence Save / reload .ttd session files
๐Ÿ“Š Reports HTML, JSON, Markdown, Plain Text output
๐Ÿ—œ Delta compression Deduplicate consecutive snapshots automatically
๐ŸŒก Two-tier cache Hot LRU cache + cold tier + optional disk overflow
๐ŸŽจ Flutter overlay Draggable debug panel with timeline scrubber & variable inspector

๐Ÿ“ฆ Installation #

dependencies:
  time_travel_debugger: ^1.0.0
dart pub get

๐Ÿš€ Quick Start #

import 'package:time_travel_debugger/time_travel_debugger.dart';

void main() async {
  final engine = TimeTravelEngine();
  engine.startRecording();

  // Option A โ€“ explicit record()
  int x = 0;
  engine.record(name: 'x', oldValue: null, newValue: x,
                file: 'main.dart', line: 8);

  for (int i = 0; i < 100; i++) {
    x = engine.track('x', x, x + i, 'main.dart', 12);
  }

  // Time-travel โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  final snap = engine.rewind(10);         // 10 steps back
  print(snap.variable('x'));              // value 10 steps ago

  final step0 = engine.jumpTo(0);         // absolute step
  print(step0.variableNames);             // all vars at that moment

  // Query โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  print(engine.firstChangeOf('x'));       // step index
  print(engine.allChangesOf('x').length); // total mutations

  // Save โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  await engine.saveSession('/tmp/debug.ttd');

  engine.dispose();
}

๐ŸŽฏ Core API #

TimeTravelEngine #

Method Description
startRecording() Begin capturing mutations
stopRecording() Stop (keeps history intact)
pauseRecording() / resumeRecording() Temporarily suspend
record({name, oldValue, newValue, file, line, ...}) Record a mutation
track<T>(name, old, new, file, line) Record + return new (inline use)
enterFunction({name, ...}) / exitFunction(...) Record function calls
annotate(label) Insert a named bookmark
rewind(n) Move cursor back n steps โ†’ returns snapshot
fastForward(n) Move cursor forward n steps
jumpTo(step) Absolute jump
currentSnapshot() Snapshot at cursor
latestSnapshot() Most recent snapshot
variablesAt(step) Map<String, dynamic> at step
firstChangeOf(name) / lastChangeOf(name) Search step indices
allChangesOf(name) All step indices for a variable
historyOf(name) List<VariableRecord> in hot memory
bookmarks() All annotated snapshots
searchRecords(query) Full-text search in descriptions
stats() PerformanceStats object
saveSession([path]) / loadSession(path) Persist to disk
clearHistory() Reset without stopping
dispose() Release all resources

StateSnapshot #

snap.variable('x')          // get value
snap.hasVariable('x')       // bool
snap.variableNames          // sorted List<String>
snap.filterVariables('pa')  // filter by pattern
snap.diff(otherSnap)        // Map<name, {before, after}>
snap.callStack              // List<CallStackFrame>
snap.currentFunction        // String? (innermost frame)
snap.withBookmark('label')  // copies with bookmark

๐Ÿ”ด Breakpoints #

final bp = BreakpointManager();

bp.addVariableBreakpoint(
  variableName: 'health',
  condition: (newVal, oldVal) => (newVal as int) < 20,
  description: 'health critical',
  action: BreakpointAction.log,      // or .pause / .throwException / .rewindAndReport
  maxHitCount: 5,
);

bp.onBreakpointFired = (event) {
  print('Breakpoint fired @ step ${event.step}: '
        '${event.trigger.variableName} = ${event.trigger.newValue}');
};

// In your recording loop:
final rec = engine.historyOf('health').last;
bp.evaluateRecord(rec, engine.currentPosition);

๐Ÿ‘ Watchpoints #

final wm = WatchpointManager();

wm.add(
  variableName: 'score',
  callback: (r) => analyticsService.track(r.newValue),
  filter: (nv, ov) => (nv as int) > (ov as int? ?? 0),
);

// After every record():
wm.notify(engine.historyOf('score').last);

๐Ÿ” DiffEngine #

const diff = DiffEngine();

final before = engine.jumpTo(0);
final after  = engine.latestSnapshot();

final result = diff.diff(after, before);
print(result.modified);   // List<DiffEntry>
print(result.added);
print(result.toText());   // pretty multi-line string

๐Ÿ“Š Reports #

final gen = ReportGenerator(
  metadata: engine.sessionMetadata,
  snapshots: [],
  records: engine.historyOf('counter'),
  stats: engine.stats(),
);

// HTML (dark-mode, table-based)
await gen.saveReport('report.html', format: ReportFormat.html);

// Markdown
await gen.saveReport('report.md', format: ReportFormat.markdown);

// JSON
final json = gen.generate(format: ReportFormat.json);

// Plain text
print(gen.generate(format: ReportFormat.plainText));

๐ŸŽจ Flutter Overlay #

void main() {
  final engine = TimeTravelEngine();
  engine.startRecording();

  runApp(
    TimeTravelWidget(
      engine: engine,
      child: MyApp(),
    ),
  );
}

The overlay adds a draggable panel with:

  • Timeline scrubber (slider + nav buttons + quick-jump field)
  • Bookmark strip for instant navigation
  • Variables tab (searchable, type-annotated, click-to-copy)
  • Call stack tab
  • Changes tab (mutations that produced this snapshot)

Open the full variable history with:

Navigator.push(context, MaterialPageRoute(
  builder: (_) => VariableInspector(
    engine: engine,
    variableName: 'counter',
  ),
));

โš™๏ธ Configuration #

TimeTravelEngine(
  config: TimeTravelConfig(
    maxHotRecords: 50000,          // records in RAM
    maxTimelineSnapshots: 20000,   // snapshots in RAM
    autoCompressInterval: Duration(seconds: 60), // null = disabled
    autoSaveInterval: Duration(minutes: 5),
    defaultSessionPath: '/tmp/app.ttd',
    appName: 'MyApp',
    appVersion: '2.0.0',
  ),
)

๐Ÿ“ Package Structure #

lib/
โ”œโ”€โ”€ time_travel_debugger.dart   # Public API (single import)
โ””โ”€โ”€ src/
    โ”œโ”€โ”€ core/
    โ”‚   โ”œโ”€โ”€ time_travel_engine.dart    โ† Main public class
    โ”‚   โ”œโ”€โ”€ state_snapshot.dart        โ† Immutable state capture
    โ”‚   โ”œโ”€โ”€ memory_recorder.dart       โ† Hot record store + index
    โ”‚   โ””โ”€โ”€ execution_timeline.dart    โ† Ordered event + snapshot log
    โ”œโ”€โ”€ models/
    โ”‚   โ”œโ”€โ”€ variable_record.dart       โ† Single mutation event
    โ”‚   โ”œโ”€โ”€ call_stack_frame.dart      โ† Call-stack frame
    โ”‚   โ”œโ”€โ”€ breakpoint_info.dart       โ† Breakpoint descriptor
    โ”‚   โ”œโ”€โ”€ timeline_event.dart        โ† Typed timeline entry
    โ”‚   โ”œโ”€โ”€ performance_stats.dart     โ† Runtime metrics
    โ”‚   โ””โ”€โ”€ session_metadata.dart      โ† Session header
    โ”œโ”€โ”€ storage/
    โ”‚   โ”œโ”€โ”€ history_storage.dart       โ† Multi-strategy warm cache
    โ”‚   โ”œโ”€โ”€ memory_cache.dart          โ† Two-tier LRU cache
    โ”‚   โ””โ”€โ”€ disk_persistence.dart      โ† .ttd file I/O
    โ”œโ”€โ”€ debugger/
    โ”‚   โ”œโ”€โ”€ breakpoint_manager.dart    โ† Conditional breakpoints
    โ”‚   โ”œโ”€โ”€ watchpoint_manager.dart    โ† Pure-observer watchpoints
    โ”‚   โ”œโ”€โ”€ diff_engine.dart           โ† Snapshot diffs
    โ”‚   โ””โ”€โ”€ report_generator.dart      โ† HTML/JSON/MD/text reports
    โ”œโ”€โ”€ ui/                            โ† Flutter widgets
    โ”‚   โ”œโ”€โ”€ time_travel_widget.dart    โ† Root overlay wrapper
    โ”‚   โ”œโ”€โ”€ snapshot_viewer.dart       โ† Variables/Stack/Changes tabs
    โ”‚   โ”œโ”€โ”€ timeline_ui.dart           โ† Scrubber + bookmarks
    โ”‚   โ””โ”€โ”€ variable_inspector.dart    โ† Full variable history page
    โ””โ”€โ”€ utils/
        โ”œโ”€โ”€ serialization.dart         โ† JSON helpers
        โ”œโ”€โ”€ compression.dart           โ† Delta + gzip + RLE
        โ”œโ”€โ”€ ttd_logger.dart            โ† Internal logger
        โ””โ”€โ”€ type_inspector.dart        โ† Runtime type display

๐Ÿ”’ Performance Notes #

  • Recording path: record() does โ‰ˆ1โ€“3 ยตs average (rolling 1 000-call window).
  • Eviction: When maxHotRecords is reached, oldest records are evicted via the onEvict hook โ€” plug in your [DiskPersistence] there.
  • Compression: Call engine.timeline.compress() or rely on the autoCompressInterval to deduplicate consecutive identical snapshots.
  • Flutter overlay: rendered only in debug builds unless showInRelease: true.

๐Ÿ“œ License #

MIT ยฉ 2026 TIMSoftDZ

0
likes
140
points
13
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Ultra-Pro time-travel debugger for Dart & Flutter that records state changes and lets you rewind execution step-by-step to inspect variables, memory, and app state at any point.

Repository (GitHub)
View/report issues

Topics

#dart #flutter #debugging #time-travel #profiler

License

MIT (license)

Dependencies

collection, flutter, json_annotation, logger, meta, uuid

More

Packages that depend on time_travel_debugger