docx_file_viewer 0.0.3 copy "docx_file_viewer: ^0.0.3" to clipboard
docx_file_viewer: ^0.0.3 copied to clipboard

A Flutter package to view DOCX files within your app. It allows users to load and display DOCX content. While the package tries to render documents accurately, some rendering issues may occur, especia [...]

Flutter DOCX Viewer Package #

This Flutter package allows you to view DOCX files in your Flutter applications. It provides a simple way to load and display DOCX content in a Flutter app.

Features #

  • Allows users to pick and view DOCX files.
  • Displays the content of the DOCX file within your app.
  • Tries to render DOCX content as accurately as possible, although some bugs may occur in certain files.

Limitations #

  • The package may not render DOCX files perfectly in all cases.
  • Some bugs are present in the rendering, and the file may not display as accurately as expected.
  • The package strives to provide a functional rendering experience, but it may not be perfect for all DOCX files.

Installation #

To use this package, follow these steps:

  1. Add the dependencies in your pubspec.yaml file:

    dependencies:
      docx_file_viewer: ^0.0.1
    
  2. Install the dependencies by running the following command:

    flutter pub get
    

Example Usage #

Below is an example of how to use the DOCX viewer in your Flutter application:

import 'dart:io';
import 'package:docx_file_viewer/docx_file_viewer.dart';
import 'package:file_picker/file_picker.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Docx Viewer'),
    );
  }
}

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

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  File? selectedFile;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: selectedFile == null
          ? const Center(
              child: Text("Select File"),
            )
          : DocxViewer(
              file: selectedFile!,
            ),
      floatingActionButton: FloatingActionButton(
        onPressed: () async {
          final file = await FilePicker.platform.pickFiles();
          if (file == null) {
            return;
          }
          final filepath = file.files.first.path!;
          setState(() {
            selectedFile = File(filepath);
          });
        },
        tooltip: 'Select DOCX File',
        child: const Icon(Icons.add),
      ),
    );
  }
}
4
likes
0
points
462
downloads

Publisher

verified publisheralihassan143cool.blogspot.com

Weekly Downloads

A Flutter package to view DOCX files within your app. It allows users to load and display DOCX content. While the package tries to render documents accurately, some rendering issues may occur, especially with complex formatting.

Repository (GitHub)
View/report issues

Topics

#docx #docxviewer #word

License

unknown (license)

Dependencies

archive, flutter, xml

More

Packages that depend on docx_file_viewer