epub_reader_highlight 1.0.0-beta.2 copy "epub_reader_highlight: ^1.0.0-beta.2" to clipboard
epub_reader_highlight: ^1.0.0-beta.2 copied to clipboard

A Flutter package for highlighting and manipulating text in EPUB files. It provides functionalities to apply different color highlights, map text indices, and format HTML tags.

example/lib/main.dart

import 'package:epub_reader_highlight/epub_reader_highlight.dart';
import 'package:epub_reader_highlight/ui/actual_chapter.dart';
import 'package:epub_reader_highlight/ui/table_of_contents.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatefulWidget {
  const MainApp({super.key});

  @override
  State<MainApp> createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> {
  late EpubController _epubReaderController;

  @override
  void initState() {
    super.initState();
    _epubReaderController = EpubController(
      document: EpubDocument.openAsset('assets/gentle-green-obooko.epub'),
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Container(
        color: Colors.white,
        child: SafeArea(
          bottom: false,
          child: Scaffold(
            backgroundColor: Colors.white,
            appBar: AppBar(
              title: EpubViewActualChapter(
                controller: _epubReaderController,
                builder: (chapterValue) => Text(
                  'Chapter: ${chapterValue?.chapter?.Title?.replaceAll('\n', '').trim() ?? ''}',
                  textAlign: TextAlign.start,
                ),
              ),
            ),
            drawer: Drawer(
              child: EpubViewTableOfContents(
                controller: _epubReaderController,
              ),
            ),
            body: EpubView(
              builders: EpubViewBuilders<DefaultBuilderOptions>(
                options: const DefaultBuilderOptions(
                  textStyle: TextStyle(
                    fontSize: 16,
                    height: 1.5,
                    color: Colors.amber,
                  ),
                ),
                chapterDividerBuilder: (_) => Container(),
              ),
              onHighlightTap: (selectedTextModel) {
                debugPrint('Highlighted Text: $selectedTextModel');
              },
              paragraphIndexOnDispose: (paragraphIndex) {
                debugPrint('Last paragraph Index: $paragraphIndex');
              },
              controller: _epubReaderController,
            ),
          ),
        ),
      ),
    );
  }
}
17
likes
0
points
36
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for highlighting and manipulating text in EPUB files. It provides functionalities to apply different color highlights, map text indices, and format HTML tags.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, epubx, equatable, flutter, flutter_html, highlight_text, html, html_unescape, scrollable_positioned_list, universal_file, xml

More

Packages that depend on epub_reader_highlight