Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting cfi as null "/6/0[null]!/4/2/4" in middle #499

Open
Himanshusha673 opened this issue Apr 3, 2024 · 1 comment
Open

getting cfi as null "/6/0[null]!/4/2/4" in middle #499

Himanshusha673 opened this issue Apr 3, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Himanshusha673
Copy link

import 'dart:async';
import 'dart:developer';
import 'dart:io';

import 'package:epub_view/epub_view.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';

class EpubViewerPage extends StatefulWidget {
final String path;
final String lastLocation;
const EpubViewerPage(
{super.key, required this.path, required this.lastLocation});

@OverRide
State createState() => _EpubViewerPageState();
}

class _EpubViewerPageState extends State {
late EpubController _epubController;
bool darkMode = false;
StreamSubscription? _chapterIndexSubscription;
StreamSubscription? _cfiSubscription;

Future _loadFromPath(String filePath) async {
final file = File(filePath);
return await file.readAsBytes();
}

@OverRide
void initState() {
super.initState();
_epubController = EpubController(
// Load document
document: EpubReader.readBook(_loadFromPath(widget.path)),
// Set start point
epubCfi: '/6/0[null]!/4/2/4',
);
}

@OverRide
Widget build(BuildContext context) => Theme(
data: darkMode ? ThemeData.dark() : ThemeData.light(),
child: Scaffold(
appBar: AppBar(
// Show actual chapter name
title: EpubViewActualChapter(
controller: _epubController,
builder: (chapterValue) => Text(
'Chapter: ' +
(chapterValue?.chapter?.Title
?.replaceAll('\n', '')
.trim() ??
''),
textAlign: TextAlign.start,
),
),
// Add a button to the AppBar actions
actions: [
IconButton(
icon: darkMode
? const Icon(Icons.light_mode)
: const Icon(Icons.dark_mode),
onPressed: () {
setState(() {
darkMode = !darkMode;
});
// Manage the button press event here
// For example, you can open a settings screen or perform any other action
},
),
],
),
// Show table of contents
drawer: Drawer(
child: GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: EpubViewTableOfContents(
controller: epubController,
loader: const CircularProgressIndicator(
color: Colors.red,
),
// itemBuilder: (context, index, chapter, itemCount) {
// return Container(
// height: 100,
// width: 100,
// color: Colors.red,
// );
// },
),
),
),
// Show epub document
body: EpubView(
builders: EpubViewBuilders(
options: const DefaultBuilderOptions(),
chapterDividerBuilder: (
) => const Divider(
color: Colors.red,
),
),
controller: _epubController,
onExternalLinkPressed: (href) {},
onDocumentLoaded: (document) {
log("Closed");
inspect(document);
},
onChapterChanged: (chapter) {
log("chapter changed");
String? loc = _epubController.epubCfi;
log(loc.toString());
},
onDocumentError: (error) {},
),
),
);
}

@Himanshusha673 Himanshusha673 added the bug Something isn't working label Apr 3, 2024
@Himanshusha673 Himanshusha673 changed the title getting cfi as null /6/0[null]!/4/2/4 in middle getting cfi as null "/6/0[null]!/4/2/4" in middle Apr 3, 2024
@abdulwahhab1
Copy link

When will this bug be fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants