epub_view 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 80

flutter_epub #

Flutter widget for view EPUB documents on all platforms. Based on epub package.

Usage example: #

import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:flutter_epub/flutter_epub.dart';
import 'package:flutter/services.dart' show rootBundle;

Future<Uint8List> _loadFromAssets(String assetName) async {
  final bytes = await rootBundle.load(assetName);
  return bytes.buffer.asUint8List();
}

@override
Widget build(BuildContext context) => Scaffold(
  body: FutureBuilder<EpubBook>(
    future: _loadFromAssets('assets/book.epub').then(EpubReader.readBook),
    builder: (_, snapshot) {
      if (snapshot.hasData) {
        return EpubReaderView(
          book: snapshot.data,
          // Called when scrolled to another chapter
          headerBuilder: (value) => AppBar(
            title: Text(
              'Chapter ${value?.chapter?.Title ?? 'Loading...'}',
            ),
          ),
          // Start from special chapter
          startFrom: EpubReaderLastPosition(3),
        );
      }

      return Center(
        child: CircularProgressIndicator(),
      );
    },
  ),
);

How start from last view position? #

This method allows you to keep the exact reading position even inside the chapter:

EpubReaderView(
  ...,
  // At first add on change callback
  onChange: (value) {
    // next get last position for save
    final lastPositionString = value.asLastPosition.toString();
    // save last position string anywhere
  }
);

// next step usage last position string:
EpubReaderView(
  startFrom: EpubReaderLastPosition.fromString(lastPositionString),
);

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

0.1.0 #

  • Initial release

example/README.md

epub_view_example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  epub_view: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:epub_view/epub_view.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
59
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
80
Learn more about scoring.

We analyzed this package on Jan 20, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
epub ^2.0.0 2.1.0
flutter 0.0.0
flutter_html ^0.11.0 0.11.1 1.0.0-pre.1
flutter_widgets ^0.1.7+1 0.1.9
Transitive dependencies
archive 2.0.13
args 1.5.2
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
dart2_constant 1.0.2+dart2
html 0.14.0+3
image 2.1.12
matcher 0.12.6
meta 1.1.8
path 1.6.4
petitparser 3.0.0
quiver 2.1.2+1
sky_engine 0.0.99
source_span 1.6.0
stack_trace 1.9.3
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
xml 3.7.0
Dev dependencies
flutter_test