zeba_academy_toc_parser
A production‑ready Flutter package for parsing and managing PDF Table of Contents (TOC) with nested structure, search support, and jump‑to‑page integration.
✨ Features
- ✅ Parse PDF bookmarks automatically
- ✅ Nested Table of Contents (multi‑level)
- ✅ Jump‑to‑page callback support
- ✅ Searchable TOC
- ✅ Ready‑to‑use TOC tree widget
- ✅ Custom UI builder support
- ✅ Null‑safe & modern Dart architecture
- ✅ Compatible with PDF viewer packages (e.g. pdfx)
📦 Installation
Add dependency in pubspec.yaml:
dependencies:
zeba_academy_toc_parser:
path: ../zeba_academy_toc_parser
(or use Git / pub.dev when published)
Then run:
flutter pub get
🚀 Quick Start
1️⃣ Import Package
import 'package:zeba_academy_toc_parser/zeba_academy_toc_parser.dart';
2️⃣ Parse TOC From PDF
final bytes = await rootBundle.load('assets/book.pdf');
final tocItems = await TocParser.parse(
bytes.buffer.asUint8List(),
);
3️⃣ Setup Controller
final controller = TocController();
controller.setItems(tocItems);
controller.onJump = (page) {
pdfController.jumpToPage(page);
};
4️⃣ Display TOC UI
TocTreeView(controller: controller)
🧠 Architecture
zeba_academy_toc_parser
├── models → TOC data structure
├── parser → PDF bookmark extraction
├── controller → state + navigation logic
├── widgets → ready UI components
└── utils → search engine
📚 Core Components
TocItem
Represents a single TOC entry.
TocItem(
title: "Chapter 1",
page: 5,
children: [...]
)
TocParser
Extracts bookmarks from a PDF document.
final toc = await TocParser.parse(pdfBytes);
TocController
Handles:
- TOC state
- Searching
- Jump navigation
controller.search("Introduction");
TocTreeView
Ready‑made nested TOC widget.
TocTreeView(controller: controller);
🔍 Search Support
controller.search("chapter");
Automatically filters the TOC tree.
🎯 Jump To Page Integration
Provide your PDF viewer navigation:
controller.onJump = (page) {
pdfController.jumpToPage(page);
};
Works with any viewer implementation.
🧩 Custom UI Builder (Advanced)
You can extend the widget to build custom TOC layouts.
Example ideas:
- Expand / Collapse sections
- Highlight active chapter
- Custom icons
- Animated navigation
⚙️ Requirements
- Flutter >= 1.17.0
- Dart SDK >= 3.8.1
📈 Use Cases
- eBook readers
- Academic PDF apps
- Religious content readers
- Documentation viewers
- Learning platforms
🧪 Testing
Run tests:
flutter test
Analyze package:
flutter analyze
🤝 Contributing
Contributions, issues, and feature requests are welcome.
- Fork the repository
- Create a feature branch
- Commit changes
- Open a pull request
📄 License
MIT License
👨💻 Maintained By
Zeba Academy
Building reusable Flutter infrastructure for scalable applications.
⭐ Support
If this package helps your project, consider giving it a star ⭐ and sharing feedback.