zeba_academy_history

A lightweight, dependency-free Flutter history management package that provides undo, redo, history stacks, checkpoints, snapshots, and history clearing with a simple and flexible API.

Perfect for Flutter applications that require state history management such as:

  • Text editors
  • Drawing applications
  • Form builders
  • Design tools
  • Note applications
  • Configuration editors
  • Data modification workflows

Features šŸš€

āœ… Undo functionality āœ… Redo functionality āœ… History stack management āœ… Configurable history limit āœ… Create checkpoints āœ… Restore checkpoints āœ… Save snapshots āœ… Retrieve snapshots āœ… Remove checkpoints āœ… Clear history āœ… Clear all stored data āœ… Generic type support āœ… Null safety āœ… No external dependencies


Installation

Add this package to your pubspec.yaml:

dependencies:
  zeba_academy_history: ^1.0.0

Then run:

flutter pub get

Import

import 'package:zeba_academy_history/zeba_academy_history.dart';

Basic Usage

Create a history manager:

final history = HistoryManager<String>();

Add History States

Store application states:

history.add("Initial");

history.add("Updated");

history.add("Final");

Undo

Move back to the previous state:

final previous = history.undo();

print(previous);

Output:

Updated

Redo

Restore the undone state:

final next = history.redo();

print(next);

Output:

Final

Checkpoints

Create named restore points:

history.createCheckpoint(
  "before_edit",
  "Before Editing",
  "Original Content",
);

Restore checkpoint:

final value =
    history.restoreCheckpoint(
      "before_edit",
    );

print(value);

Snapshots

Save temporary states:

history.saveSnapshot(
  "draft",
  "Draft Content",
);

Retrieve snapshot:

final snapshot =
    history.getSnapshot("draft");

print(snapshot);

History Information

Check undo availability:

if(history.canUndo){
  print("Undo available");
}

Check redo availability:

if(history.canRedo){
  print("Redo available");
}

Get history count:

print(history.historyLength);

Clear History

Remove undo and redo states:

history.clearHistory();

Clear Everything

Remove history and checkpoints:

history.clearAll();

Custom History Limit

Control stored history size:

final history =
    HistoryManager<int>(
      maxHistory: 100,
    );

Example

final manager =
    HistoryManager<int>();


manager.add(10);

manager.add(20);

manager.add(30);


print(
  manager.undo(),
);


print(
  manager.redo(),
);

Why Use zeba_academy_history?

Flutter applications often need reliable state tracking.

Instead of manually creating undo and redo logic, this package provides:

  • Clean API
  • Reusable architecture
  • Generic state handling
  • Simple integration
  • Lightweight implementation

Supported Flutter Versions

Flutter Supported
Flutter 3.x āœ…
Dart 3.x āœ…

Package Structure

lib/
│
ā”œā”€ā”€ zeba_academy_history.dart
│
└── src/
    ā”œā”€ā”€ history_manager.dart
    ā”œā”€ā”€ history_entry.dart
    └── history_checkpoint.dart

License

This project is licensed under the GNU General Public License v3.0 (GPL-3.0).

You are free to:

āœ… Use āœ… Modify āœ… Share āœ… Distribute

under the conditions of the GPL-3.0 license.

See the LICENSE file for complete details.


About Me

✨ I’m Sufyan bin Uzayr, an open-source developer passionate about building and sharing meaningful projects.

You can learn more about me and my work at:

sufyanism.com

or connect with me on:

LinkedIn


Zeba Academy šŸš€

Your all-in-one learning hub!

Explore courses and resources in coding, technology, and development at:

Zeba Academy is a learning platform dedicated to coding, technology, and development.

Learn through:

  • Practical tutorials
  • Real-world projects
  • Hands-on coding experience
  • Developer-focused resources

Connect With Zeba Academy

🌐 Website: https://zeba.academy

šŸ’» Learning Platform: https://code.zeba.academy

ā–¶ YouTube: https://www.youtube.com/@zeba.academy

šŸ“ø Instagram: https://www.instagram.com/zeba.academy/


Thank you for visiting! ⭐

Happy Coding with zeba_academy_history šŸš€