ReadingPosition class
Represents the current reading position in an EPUB.
This class provides comprehensive position tracking including:
- Chapter index and title
- Paragraph index within the book
- Reading progress as a percentage
Positions can be serialized to JSON for persistent storage.
Constructors
- ReadingPosition({required int chapterIndex, required int paragraphIndex, String? chapterTitle, required int totalParagraphs, double paragraphOffset = 0.0})
-
const
-
ReadingPosition.fromJson(Map<
String, dynamic> json) -
Create from JSON.
factory
- ReadingPosition.initial({int totalParagraphs = 0})
-
Create an initial position (start of book).
factory
Properties
- chapterIndex → int
-
Index of the current chapter in the flat chapter list.
final
- chapterTitle → String?
-
Title of the current chapter (may be null for untitled chapters).
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- isAtEnd → bool
-
Whether this position is at the end of the book.
no setter
- isAtStart → bool
-
Whether this position is at the beginning of the book.
no setter
- paragraphIndex → int
-
Index of the current paragraph in the entire book.
final
- paragraphOffset → double
-
Scroll offset within the current paragraph (0.0 to 1.0).
final
- progressPercent → double
-
Calculate the reading progress as a percentage (0-100).
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- totalParagraphs → int
-
Total number of paragraphs in the book (for progress calculation).
final
Methods
-
copyWith(
{int? chapterIndex, int? paragraphIndex, String? chapterTitle, int? totalParagraphs, double? paragraphOffset}) → ReadingPosition - Create a copy with modified properties.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Convert to JSON for persistent storage.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override