flutter_document_viewer 0.1.0+1 copy "flutter_document_viewer: ^0.1.0+1" to clipboard
flutter_document_viewer: ^0.1.0+1 copied to clipboard

Docx, PPTX, pdf viewer for flutter

Flutter Document Viewer #

style: very good analysis Powered by Mason License: MIT

A powerful document viewer for Flutter that supports docx, PPTX, and PDF files.

Installation 💻 #

❗ In order to start using Flutter Document Viewer you must have the Flutter SDK installed on your machine.

Install via flutter pub add:

dart pub add flutter_document_viewer

Or

dependencies:
  flutter_document_viewer: ^0.1.0

🚀 Example Usage #

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

class DocumentViewerExample extends StatefulWidget {
  const DocumentViewerExample({super.key, required this.title});

  final String title;

  @override
  State<DocumentViewerExample> createState() => _DocumentViewerExampleState();
}

class _DocumentViewerExampleState extends State<DocumentViewerExample> {
  // Sample PPTX file URL
  final String pptxUrl = 'https://www.unm.edu/~unmvclib/powerpoint/pptexamples.ppt';
  
  // Controller for the document viewer
  late final FlutterDocumentViewerController _controller;
  bool _showControls = true;

  @override
  void initState() {
    super.initState();
    _controller = FlutterDocumentViewerController(
      onReady: () {
        ScaffoldMessenger.of(context).showSnackBar(
          const SnackBar(content: Text('Document viewer is ready')),
        );
      },
      onPageChanged: (currentPage, totalPages) {
        debugPrint('Page changed to $currentPage of $totalPages');
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        actions: [
          IconButton(
            icon: Icon(_showControls ? Icons.visibility_off : Icons.visibility),
            onPressed: () {
              setState(() {
                _showControls = !_showControls;
              });
            },
            tooltip: 'Toggle controls visibility',
          ),
        ],
      ),
      body: Column(
        children: [
          Expanded(
            child: FlutterDo cumentViewer(
              url: pptxUrl,
              controller: _controller,
              showControls: _showControls,
              onPageChanged: (currentPage, totalPages) {
                debugPrint('Page changed callback: $currentPage of $totalPages');
              },
            ),
          ),
          Padding(
            padding: const EdgeInsets.all(16.0),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                ElevatedButton(
                  onPressed: () => _controller.gotoPage(1),
                  child: const Text('First Page'),
                ),
                ElevatedButton(
                  onPressed: () => _controller.gotoPage(_controller.totalPages),
                  child: const Text('Last Page'),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

Refer to the main.dart in the example directory for a complete implementation.

Features #

  • 📄 Support for multiple document formats (PDF, PPTX, DOCX)
  • 🔍 Page navigation controls
  • 📱 Responsive design
  • 🎮 Custom controller for programmatic navigation
  • 👁️ Toggleable navigation UI
  • 🔔 Event callbacks for viewer ready and page changes

Screenshots #

Document View Navigation Controls

🐛 Bugs/Requests #

Pull requests are welcome. If you have any feature requests or find bugs, please open an issue.

Continuous Integration 🤖 #

Flutter Document Viewer comes with a built-in GitHub Actions workflow powered by Very Good Workflows but you can also add your preferred CI/CD solution.

Out of the box, on each pull request and push, the CI formats, lints, and tests the code. This ensures the code remains consistent and behaves correctly as you add functionality or make changes. The project uses Very Good Analysis for a strict set of analysis options used by our team. Code coverage is enforced using the Very Good Workflows.


4
likes
150
points
14
downloads

Publisher

verified publisherpeterakande.com

Weekly Downloads

Docx, PPTX, pdf viewer for flutter

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, webview_flutter

More

Packages that depend on flutter_document_viewer