epub_view_enhanced

Last updated:

0 purchases

epub_view_enhanced Image
epub_view_enhanced Images
Add to Cart

Description:

epub view enhanced

epub_view #
Pure flutter widget (non native) for view EPUB documents on all platforms. Based on epub package. Render with flutter widgets (not native view) on any platforms: Web, MacOs, Windows Linux, Android and iOS
Showcase #

Getting Started #
In your flutter project add the dependency:
flutter pub add epub_view
copied to clipboard
Usage example: #
import 'dart:typed_data';

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

late EpubController _epubController;

@override
void initState() {
super.initState();
_epubController = EpubController(
// Load document
document: EpubDocument.openAsset('assets/book.epub'),
// Set start point
epubCfi: 'epubcfi(/6/6[chapter-2]!/4/2/1612)',
);
}

@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
// Show actual chapter name
title: EpubViewActualChapter(
controller: _epubController,
builder: (chapterValue) => Text(
'Chapter: ' + (chapterValue?.chapter?.Title?.replaceAll('\n', '').trim() ?? ''),
textAlign: TextAlign.start,
)
),
),
// Show table of contents
drawer: Drawer(
child: EpubViewTableOfContents(
controller: _epubController,
),
),
// Show epub document
body: EpubView(
controller: _epubController,
),
);
copied to clipboard
How start from last view position? #
This method allows you to keep the exact reading position even inside the chapter:
_epubController = EpubController(
// initialize with epub cfi string for open book from last position
epubCfi: 'epubcfi(/6/6[chapter-2]!/4/2/1612)',
);

// Attach controller
EpubView(
controller: _epubController,
);

// Get epub cfi string
// for example output - epubcfi(/6/6[chapter-2]!/4/2/1612)
final cfi = _epubController.generateEpubCfi();

// or usage controller for navigate
_epubController.gotoEpubCfi('epubcfi(/6/6[chapter-2]!/4/2/1612)');
copied to clipboard
Api #
Open document #
Local document open:
EpubDocument.openAsset('assets/sample.pdf')

EpubDocument.openData(FutureOr<Uint8List> data)

// Not supports on Web
EpubDocument.openFile('path/to/file/on/device')
copied to clipboard
Network document open:
Install [network_file] package (supports all platforms):
flutter pub add internet_file
copied to clipboard
And use it
import 'package:internet_file/internet_file.dart';

// The cors policy is required on the server.
// You can raise your cors proxy.
EpubDocument.openData(InternetFile.get('https://link.to/book.epub'))
copied to clipboard
Control document #
// Get epub cfi string of actual view insets
// for example output - epubcfi(/6/6[chapter-2]!/4/2/1612)
final cfi = _epubController.generateEpubCfi();

// Navigate to paragraph in document
_epubController.gotoEpubCfi('epubcfi(/6/6[chapter-2]!/4/2/1612)');
copied to clipboard
Document callbacks #
EpubView(
controller: epubController,

onExternalLinkPressed: (href) {},

onDocumentLoaded: (document) {},
onChapterChanged: (chapter) {},
onDocumentError: (error) {},
);
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.