book_reader 0.1.22 copy "book_reader: ^0.1.22" to clipboard
book_reader: ^0.1.22 copied to clipboard

PlatformAndroid

A widget used to read a book.

example/main.dart

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

void main() {
  runApp(const MaterialApp(
    home: BookReaderDemo(),
  ));
}

class BookReaderDemo extends StatelessWidget {
  const BookReaderDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ElevatedButton(
          onPressed: () => handlePressed(context),
          child: const Text('Book Reader'),
        ),
      ),
    );
  }

  void handlePressed(BuildContext context) {
    Navigator.of(context).push(
      MaterialPageRoute(
        builder: (context) => BookReader(
          author: 'author',
          cover: Image.network('cover image src'),
          future: fetchChapter,
          name: 'Book Reader Demo',
        ),
      ),
    );
  }

  Future<String> fetchChapter(int index) async {
    return Future.value('$index');
  }
}