GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - polymorph001/epub_viewer: A Flutter package for viewing Epub documents

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

38 Commits
38 Commits

Folders and files

NameName
Last commit message
Last commit date
example
example
 
 
lib
lib
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.metadata
.metadata
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
analysis_options.yaml
analysis_options.yaml
 
 
pubspec.yaml
pubspec.yaml
 
 

Repository files navigation

A Flutter package for viewing Epub documents, developed by combining the power of Epubjs and flutter_inappwebview

Features

  • Highlight text
  • Search in Epub
  • List chapters
  • Text selection
  • Highly customizable UI
  • Resume reading using cfi
  • Custom context menus for selection

Limitations

  • Loading from local files and assets is not supported

Getting started

In your Flutter project add the dependency:

flutter pub add epub_viewer
  • Important: Complete the platfrom-wise setup from here

  • Enable clear text traffic, instructions here

Make sure to follow and complete each step

Usage

Basic usage

import 'package:epub_viewer/epub_viewer.dart';
import 'package:flutter/material.dart';

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final epubController = EpubController();

  var textSelectionCfi = '';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
          child: Column(
        children: [
          Expanded(
            child: EpubViewer(
              epubUrl: 'https://s3.amazonaws.com/moby-dick/OPS/package.opf',
              epubController: epubController,
              displaySettings:
                  EpubDisplaySettings(flow: EpubFlow.paginated, snap: true),
              onChaptersLoaded: (chapters) {},
              onEpubLoaded: () async {},
              onRelocated: (value) {},
              onTextSelected: (epubTextSelection) {},
            ),
          ),
        ],
      )),
    );
  }
}

Parameters and callbacks

//Epub controller to manage epub
final  EpubController  epubController;

///Epub url to load epub from network
final  String  epubUrl;

///Epub headers to load epub from network
final  Map<String, String> headers;

///Initial cfi string to specify which part of epub to load initially
///if null, the first chapter will be loaded
final  String?  initialCfi;

///Call back when epub is loaded and displayed
final  VoidCallback?  onEpubLoaded;

///Call back when chapters are loaded
final  ValueChanged<List<EpubChapter>>?  onChaptersLoaded;

///Call back when epub page changes
final  ValueChanged<EpubLocation>?  onRelocated;

///Call back when text selection changes
final  ValueChanged<EpubTextSelection>?  onTextSelected;

///initial display settings
final  EpubDisplaySettings?  displaySettings;

///context menu for text selection
///if null, the default context menu will be used
final  ContextMenu?  selectionContextMenu;

Methods

///Move epub view to a specific area using Cfi string or chapter href
epubController.display(cfi:cfiString) 

///moves to next page
epubController.next()

///Moves to the previous page in epub view
epubController.prev()

///Returns the current location of epub viewer
epubController.getCurrentLocation()

///Returns list of [EpubChapter] from epub,
/// should be called after onChaptersLoaded callback, otherwise returns empty list
epubController.getChapters()

///Search in epub using query string
///Returns a list of [EpubSearchResult]
epubController.search(query:query)

///Adds a highlight to epub viewer
epubController.addHighlight(
	cfi:cfiString,
	color:color
	opacity:0,5
)

///remove hightlight
epubController.removeHighlight(cfi:cfi)

///Set [EpubSpread] value
epubController.setSpread(spread:spread)

///Set [EpubFlow] value
epubController.setFlow(flow:flow)

///Set [EpubManager] value
epubController.setManager(manager:manager)

///Adjust font size in epub viewer
epubController.setFontSize(fontSize:16)

Known Issues

  • onRelocated callback is broken when snap in epubDisplaySettings==true

Upcoming features

  • More annotations (underline, mark etc)
  • Text extraction
  • More callbacks (rendered, error etc)
  • Support for local files and assets

About

A Flutter package for viewing Epub documents

pub.dev/packages/flutter_epub_viewer

Resources

Readme
License
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.