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:
or connect with me on:
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 š